-
Great work on MDX v2! I especially appreciate the updated new v2 docs! I'm learning v2 by practicing against the Playground page code, but couldn't quite figure out how to scope in React components when evaluating. Here's codesandbox of what I learned out so far Based on the v2 Docs, I should able to pass the component props via the MXProvider and useuseMDXComponents:
But that doesn't work. I was able to style existing components by passing components directly into the evaluated result:
But any custom React components simply wouldn't show up from the evaluated code. Am I missing something obvious here? Edit: I think I figured it out the problem, it's the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Thanks for the kind words, means a lot! Evaluate gives you a component (as default): const MDXContentComponent = await evaluate(code, {...}).default You can then pass components to that component: <MDXContentComponent components={...} />
Can you please explain with an example what you tried, what you expected, and what didn’t work?
I think so :) the
Why are you using sanitize? If it is to provide security for unsafe user generated MDX, that won’t work. |
Beta Was this translation helpful? Give feedback.
Thanks for the kind words, means a lot!
Evaluate gives you a component (as default):
You can then pass components to that component:
Can you please explain with an example what you tried, what you expected, and what didn’t work?
I think so :) the
default
result fromevaluate
is exactly the same as what you’d get when importing an MDX file. So the whole § Using MDX section applies!Why a…