Open scottyob opened 1 year ago
Try using regular html img tags, that worked for me.
Noting that I saw this too, and did a lot of digging into workarounds. It seems to be an issue of not working on server components, which your repo would be. Doing some slight modifications and adding 'use client' to the post/[slug]/page.tsx
allowed the image to show up but that defeats the purpose and also the capability of the generateStaticParams
function
Trying to follow the instructions in this section leads to a different but related error of
- error node_modules/@mdx-js/react/lib/index.js (34:26) @ React
- error createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component
at eval (webpack-internal:///(sc_server)/./node_modules/@mdx-js/react/lib/index.js:38:73)
@tannerabread I've bumped into numerous issues when using dynamic imports together with MDX. Using either pnpm or turbo results in different errors, one of them being this one and another here
So far, using "use client"
and static imports has been the only reliable method.
@tannerabread I've bumped into numerous issues when using dynamic imports together with MDX. Using either pnpm or turbo results in different errors, one of them being this one and another here
So far, using
"use client"
and static imports has been the only reliable method.
I gave it a whirl, looks like "use client" is a no go for me.
Seems if I want to dynamically show mdx content in a page, I'm going to need to go down the route of using something like next-mdx-remote and some webpack config for my images until this gets supported/bugfixed?
Try using regular html img tags, that worked for me.
This does indeed if using MyImg.src
Verify canary release
Provide environment information
Which area(s) of Next.js are affected? (leave empty if unsure)
Image optimization (next/image, next/legacy/image), MDX (@next/mdx)
Link to the code that reproduces this issue or a replay of the bug
https://github.com/scottyob/nextjs-mdx-issue
To Reproduce
See:
To reproduce, you can clone bug repo: https://github.com/scottyob/nextjs-mdx-issue Url: http://localhost:3000/post/a
Describe the Bug
When importing an mdx file that uses nextjs/image to dynamically render a component:
We get the error:
Terminal:
Expected Behavior
It renders with picture!
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response