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: Element type is invalid: expected a string (for built-in components) #207

Open
web-programmer-here opened this issue Jan 13, 2023 · 1 comment

Comments

@web-programmer-here
Copy link

I am getting an error when rendering the MDX content using nextjs 13 and react 18.

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.

I think the error is coming from here:

return <MDXLayout layout={layout} components={MDXComponents} {...rest} />
export const MDXComponents = {
	Image,
	TOCInline,
	a: CustomLink,
	pre: Pre,
	wrapper: ({ components, layout, ...rest }) => {
		const Layout = require(`../layouts/${layout}`).default
		return <Layout {...rest} />
	},
}

export default function MDXLayoutRenderer({ layout, mdxSource, ...rest }) {
	const MDXLayout = useMemo(() => getMDXComponent(mdxSource), [mdxSource])

	return <>Test</>
        // error coming from this line
	//return <MDXLayout layout={layout} components={MDXComponents} {...rest} />
}
"next": "13.1.2",
"react": "18.2.0",
"esbuild": "^0.16.17",
"mdx-bundler": "^9.2.1",

I am not sure why I get this error. Thanks

@medkrimi
Copy link

Downgrade to next@12.3.4

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

2 participants