You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a NextJS application, when I use MDXRemote within a client component, the console shows the following error:
Internal error: Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
The error above occurs on production build as well.
How to reproduce:
next: v14.2.10 typescript: v5.1.6 next-mdx-remote: v4.4.1 (happens on v5.0.0 as well)
Initialize a typical NextJS with Typescript
Create a test page (Ex: app/test/page.tsx)
Define a normal NextPage like below:
import { serialize } from 'next-mdx-remote/serialize';
import TestComponent from '@/app/test-mdx/TestComponent';
const TestMdx = async () => {
const mdxSource = await serialize('### This is a header');
return (
<TestComponent source={mdxSource} />
);
};
export default TestMdx;
Refresh the browser by clicking the refresh button
Check the console (both server and client)
Note: the example above is just a simple way to reproduce the problem I had. Some of you might suggest importing from next-mdx-remote/rsc and in fact, the error above did not occur in the server component setup. But in my real application, I have to use MDXRemote within a client component, that's why I created the code above to test. It turned out that the simple setup above is enough to get the error (at first I thought it was because of the custom components that I pass into MDXRemote).
Describe the bug
In a NextJS application, when I use MDXRemote within a client component, the console shows the following error:
Internal error: Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
The error above occurs on production build as well.
How to reproduce:
next
: v14.2.10typescript
: v5.1.6next-mdx-remote
: v4.4.1 (happens on v5.0.0 as well)app/test/page.tsx
)TestComponent
component/test-mdx
Note: the example above is just a simple way to reproduce the problem I had. Some of you might suggest importing from
next-mdx-remote/rsc
and in fact, the error above did not occur in the server component setup. But in my real application, I have to use MDXRemote within a client component, that's why I created the code above to test. It turned out that the simple setup above is enough to get the error (at first I thought it was because of the custom components that I pass intoMDXRemote
).Reproduction
https://github.com/ChunML/next-mdx-error
next-mdx-remote version
v4.4.1 (can reproduce on v5.0.0 too)
The text was updated successfully, but these errors were encountered: