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

Unable to import MDXContent with React 19 beta #458

Closed
dstaley opened this issue May 9, 2024 · 3 comments
Closed

Unable to import MDXContent with React 19 beta #458

dstaley opened this issue May 9, 2024 · 3 comments
Labels
v5 Issues and PRs for v5

Comments

@dstaley
Copy link
Contributor

dstaley commented May 9, 2024

⨯ Error: Functions cannot be passed directly to Client Components unless you explicitly expose it by marking it with "use server". Or maybe you meant to call this function rather than return it.
  {$$typeof: ..., type: function MDXContent, key: ..., ref: ..., props: ..., _owner: ..., _store: ...}
                        ^^^^^^^^^^^^^^^^^^^
    at stringify (<anonymous>)
@dstaley dstaley added the v5 Issues and PRs for v5 label May 9, 2024
@karlhorky
Copy link

karlhorky commented May 16, 2024

Reproduction:

  1. Use npx create-next-app@canary (our app has [email protected])
  2. In a Server Component (eg a page), import and use this component (no Client Component necessary)
import { MDXRemote } from 'next-mdx-remote/rsc';

export default function Notes() {
  return (
    <MDXRemote source="abc" />
  );
}

In our app, we also have "react" and "react-dom" set to 18.3.1 in package.json, but Next.js has its own compiled React version internally.

@dstaley
Copy link
Contributor Author

dstaley commented May 16, 2024

@karlhorky Thank you so much! The important detail there is having [email protected] in package.json. This issue does not reproduce if package.json contains [email protected]. I think there's some interaction between the v19 copy of React and the v18 copy that's causing this issue. I don't think we're going to have a stable release of either before v5, so this might need to be fixed once the dust settles because as it presents now I don't know if this is an actual issue or just a weird bug that's a result of mismatched React versions.

@dstaley
Copy link
Contributor Author

dstaley commented May 17, 2024

I just received confirmation from the Next.js team that Next 15 will require React 19. This error only occurs when Next 15 (which is what the canary will be) is used with React 18, so I'm going to go ahead and close this.

@dstaley dstaley closed this as completed May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v5 Issues and PRs for v5
Projects
None yet
Development

No branches or pull requests

2 participants