Parse string prop as markdown #2274
Answered
by
remcohaszing
edward1127
asked this question in
Q&A
-
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.
Answered by
remcohaszing
Mar 23, 2023
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.
4 replies
Answer selected by
edward1127
-
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.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
.