Skip to content
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

Element rendered from older version of React error with latest next@canary releases #467

Open
hamlim opened this issue Jul 8, 2024 · 8 comments

Comments

@hamlim
Copy link

hamlim commented Jul 8, 2024

Describe the bug

I get the following error in development and in production when using next-mdx-remote/rsc within my Next.js application:

Error: A React Element from an older version of React was rendered. This is not supported. It can happen if:
- Multiple copies of the "react" package is used.
- A library pre-bundled an old copy of "react" or "react/jsx-runtime".
- A compiler tries to "inline" JSX instead of using the runtime.

My hunch is that it is because of the dynamic require of the jsx-runtime, however this could also be a bug in Next.

Reproduction

https://github.com/hamlim/next-mdx-remote-jsx-runtime-bug

next-mdx-remote version

v5.0.0

@hamlim
Copy link
Author

hamlim commented Jul 8, 2024

I'll cross report to Next as well, just in case it's an issue on their end!

@hamlim
Copy link
Author

hamlim commented Jul 9, 2024

Added this comment on my Next.js related issue as well:

My hunch is that this code within that package is the problematic part: hashicorp/next-mdx-remote@17d6598/src/jsx-runtime.cjs#L11-L15

@dominik-sfl
Copy link

Are there any news on this? Were you able to figure something out?

@hamlim
Copy link
Author

hamlim commented Sep 16, 2024

I ended up effectively "forking" this package into our codebase to fix this issue - we weren't relying on too many core parts of the library and instead just needed to use MDX directly to transform the content on the fly.

@beamcode
Copy link

Any fixes to share?

@eposha
Copy link

eposha commented Oct 22, 2024

Next.js 15 same issue

@akgec-saurabh
Copy link

akgec-saurabh commented Oct 23, 2024

using transpilePackages: ["next-mdx-remote"], in next config remove the error for nextjs 15
https://github.com/hashicorp/next-mdx-remote?tab=readme-ov-file#installation

@ryanleichty
Copy link

I was running into the same issue using the portfolio template. Adding transpilePackages: ['next-mdx-remote'] to the next config solved the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants