Dynamically imported client component with variable name returns error in dev but works fine in prod #44946
Labels
template: bug
A user has filled out the bug report template. Issue needs triaging
Verify canary release
Provide environment information
Operating System:
Platform: darwin
Arch: x64
Version: Darwin Kernel Version 22.2.0: Fri Nov 11 02:08:47 PST 2022; root:xnu-8792.61.2~4/RELEASE_X86_64
Binaries:
Node: 16.17.0
npm: 8.15.0
Yarn: 1.22.19
pnpm: N/A
Relevant packages:
next: 13.1.2
eslint-config-next: 13.1.2
react: 18.2.0
react-dom: 18.2.0
Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true), Dynamic imports (next/dynamic)
Link to the code that reproduces this issue
https://stackblitz.com/edit/vercel-next-js-zxfkvg?file=app/page.tsx
To Reproduce
yarn dev
Describe the Bug
When dynamically importing a client component with variable name which uses React context, next returns error on dev but works fine on prod. Note: dynamic import with static name works in both environment.
Expected Behavior
yarn dev
errors and the error saysTypeError: Cannot read properties of null (reading 'useContext')
yarn build && yarn start
works fine.Which browser are you using? (if relevant)
Chrome
How are you deploying your application? (if relevant)
Vercel
The text was updated successfully, but these errors were encountered: