I am using NextJS and MDX with next-mdx-remote
to get my data and it successfully work but the only problem is whenever I try to import react components I get the following error
Error: Expected component
CodeBlock
to be defined: you likely forgot to import, pass, or provide it. It’s referenced in your code at317:1-317:24
In short :
This Works -
---
title: 'First Blog Post'
author: 'Me'
publishDate: 'Nov 4th, 2023'
---
# This is our first post
Here is a regular paragraph
here is a list:
- Item one
- Item two
- Item three
## This is an h2 element
This Does Not -
---
title: 'First Blog Post'
author: 'Me'
publishDate: 'Nov 4th, 2023'
---
# This is our first post
Here is a regular paragraph
here is a list:
- Item one
- Item two
- Item three
<CodeBlock></CodeBlock>
## This is an h2 element
Below are the following files
- index.js for MDX
- articles/[slug]/page.js
- package.json
Updated:
- mdx-components.js
According to
next-mdx-remote
documentation here:The rationale seems to be that because
next-mdx-remote
is intended to load content from anywhere rather than just local content, they don't support local imports directly.