next.js: Usage of Recoil in Nextjs app (turborepo) induces a TypeError: Cannot destructure property 'ReactCurrentDispatcher.
Link to the code that reproduces this issue
https://github.com/tsdineshjai/PayTM_Repo
To Reproduce
- NPM install globally (so that recoil package is also installed, that is the one causing issue)
- Navigate to apps/user-app and npm run dev
- Click localhost:3000
Current vs. Expected behavior
I have added store as package in the turborepo, which contains Recoil as state management. A hook named “useBalance” was added, which returns the state of an atom.(basic unit of recoil). Exported the hook file. Added the “store” package as dependency to the Next.js app. The issue arises whenever I try to invoke “useBalance” hook in the Next.js app.
The expected result should be a text on the page showing “the balance is 0”, instead we get a unhandled runtime error.
Provide environment information
Operating System:
Platform: win32
Arch: x64
Version: Windows 11 Home Single Language
Available memory (MB): 24303
Available CPU cores: 8
Binaries:
Node: 20.10.0
npm: 10.8.1
Relevant Packages:
next: 15.0.0-rc.0 // Latest available version is detected (15.0.0-rc.0).
eslint-config-next: 15.0.0-rc.0
react: 19.0.0-rc-f994737d14-20240522
react-dom: 19.0.0-rc-f994737d14-20240522
typescript: 5.4.5
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Not sure, Output (export/standalone)
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
I have already raised the issue in turborepo GitHub repo as a discussion, assuming this is an issue related to turborepo. link: https://github.com/vercel/turbo/discussions/8373
I have been redirected here to post as an issue to get a guidance on the issue.
Note : There is no issue for the same code if it’s a standalone application of turbopack. But it arises while using it in monorepo.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 15
To make it work in your current directory: go to your apps/your-app folder which is using the release candidate version and do:
pnpm remove next react react-domthen install all the stable versions by doing:pnpm add next@latest react@latest react-dom@latestalso make sure to do a install on your root folder as well by doing:pnpm inow it should workpnpm run dev