Skip to content

What's the right way to scoped in custom components when evaluate with @mdx-js/mdx? (2.0.0-rc1) #1787

Answered by wooorm
xHomu asked this question in Q&A
Discussion options

You must be logged in to vote

Great work on MDX v2! I especially appreciate the updated new v2 docs!

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={...} />

But any custom React components simply wouldn't show up from the evaluated code.

Can you please explain with an example what you tried, what you expected, and what didn’t work?

Am I missing something obvious here?

I think so :) the default result from evaluate is exactly the same as what you’d get when importing an MDX file. So the whole § Using MDX section applies!

Edit

Why a…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@xHomu
Comment options

@wooorm
Comment options

Answer selected by xHomu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants