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

Error: Cannot read properties of null (reading 'useState') - package not working with Next.JS 14 #472

Open
hassanzadeh opened this issue Sep 7, 2024 · 2 comments

Comments

@hassanzadeh
Copy link

hassanzadeh commented Sep 7, 2024

Describe the bug

Hey Guys,
MDXRemote does not work on Next.JS 14 with app-based routing. Have you tested it? I saw someone said she imported MDXRemote 'next-mdx-remote/rsc", but that doesn't make sense, not sure what she did.

Thanks for the help

Reproduction

`.
const BlogPost = async ({
params,
}: {
params: { slug: string; category_or_slug: string };
}) => {
const post = await getPost(params.category_or_slug, params.slug);

if (!post) return notFound();

const {
subject,
content,
createdAt,
authors,
tags,
postCategories,
relevantPosts,
} = post;

const mdxSource = await serialize(content, {
scope: {},
mdxOptions: {
rehypePlugins: [rehypeCodeTitles, rehypeKatex], //Looks like rehypePrism is not working with next js 14!!!
remarkPlugins: [remarkMath, remarkGfm],
},
parseFrontmatter: true,
});

...

<MDXRemote
{...mdxSource}

                components={components}
              />

`

next-mdx-remote version

v5

@hassanzadeh
Copy link
Author

hassanzadeh commented Sep 8, 2024

For those facing this, compileMDX fixed it. However, I dont think the rehype plugins are accepted as i'm getting ts warnings when passing them.
image

@hassanzadeh
Copy link
Author

hassanzadeh commented Sep 9, 2024

I can confirm that this package is no longer working with rehypeKatex and probably other plugins. Previously simple formula like: x = \frac{1}{\sqrt{2}} where being compiled without any problem but now it results in this error:
An error occurred!
[next-mdx-remote] error compiling MDX: Could not parse expression with acorn More information: https://mdxjs.com/docs/troubleshooting-mdx

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

1 participant