-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 BUG: React + MDX: React is not defined #4084
Comments
@cameronmcefee issue got fixed after importing react from react in Component.jsx You can checkout this, |
Thanks @Aayush27032001, but that seems like a bandaid. Prior to adding the MDX integration, React is available and importing it is not necessary. After adding the MDX integration it is not, presumably indicating the MDX integration is manipulating something it probably shouldn't — or the docs should be updated to describe the expectations of the new behavior. Also worth noting, the symptomatic behavior happens in a non-MDX file, so the MDX integration may be making changes beyond its scope. |
Ok, after spelunking a bit, I found what I think is the cause — I just don't know the appropriate way to resolve things. In https://github.com/withastro/astro/blob/main/packages/astro/src/core/config.ts#L350-L354 there is a conditional that loads a specific render for MDX. That will load in this render: https://github.com/withastro/astro/blob/main/packages/astro/src/jsx/renderer.ts The render points |
Here's a reduced version: https://stackblitz.com/edit/github-kgkmxz-yig8qb?file=src%2Fpages%2Findex.astro,astro.config.mjs |
What version of
astro
are you using?1.0.0-rc.2
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
yarn
What operating system are you using?
Mac
Describe the Bug
Hello,
In the example provided, I have the Just the Basics template, with all updated dependencies, plus the React and MDX integrations. With just the React integration, things work as expected, but with the addition of the MDX integration, things fail with "React is not defined", attributed to the React integration.
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-kgkmxz?file=src/pages/index.astro
Participation
The text was updated successfully, but these errors were encountered: