Parse string prop as markdown #2274
-
How can I parse a string prop (props.content in the example below) as markdown within a mdx file?
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
MDX does not compile props. If you pass props as a string, you get them as a string. If you want to treat the content as markdown, you can use something like |
Beta Was this translation helpful? Give feedback.
-
You shouldn’t, probably. It’s the same question: “Parse string prop as JavaScript”. You shouldn’t. You can write JavaScript in JavaScript. You shouldn’t use strings for that. You can do it of course, with an eval function (we have one too), but it’s typically unsafe, slow, and a really bad idea. |
Beta Was this translation helpful? Give feedback.
MDX does not compile props. If you pass props as a string, you get them as a string. If you want to treat the content as markdown, you can use something like
react-markdown
.