Backstory (Skip it if you want)
Ok so I was **REALLY **struggling with this one.
I’m building an app, and for ease of use and maintenance, for the terms and conditions, privacy policy and other stuff I wanted to write them in markdown instead of plain TSX.
I could not find anything on my particular environment: Vite + React + Typescript + ChakraUI.
So here’s what worked for me:
The solution
Test your markdown flow
First thing’s first, get your markdown rendering straight:
Install react-markdown :
npm i react-markdown
Enter fullscreen mode
Exit fullscreen mode
If you don’t use ChakraUI skip this step:
Install chakra-ui-markdown-renderer :
ChakraUI messes with the typical <h2> and other HTML stuff, so react-markdown won’t work unless we pass a custom renderer:
npm i chakra-ui-markdown-renderer
Enter fullscreen mode
Exit fullscreen mode
Now create a simple component to test your markdown:
import { Box } from " @chakra-ui/react " ; import ReactMarkdown from " react-markdown " ; import…