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

Vitest >= 0.32 "This component must be used inside a <RecoilRoot> component." #31

Open
Kamahl19 opened this issue Sep 18, 2023 · 5 comments

Comments

@Kamahl19
Copy link

After upgrading from Vitest 0.31.4 to 0.32.0 I am getting

Error: This component must be used inside a <RecoilRoot> component.
    at err (/node_modules/recoil/cjs/index.js:22:17)
    at Object.notInAContext (/node_modules/recoil/cjs/index.js:4182:9)
    at /node_modules/recoil/cjs/index.js:3975:90
    at memoizedFn (/node_modules/recoil/cjs/index.js:3615:17)
    at cloneSnapshot (/node_modules/recoil/cjs/index.js:3981:20)
    at Object.snapshot (/node_modules/recoil/cjs/index.js:6109:26)
    at Object.get (/node_modules/recoil/cjs/index.js:2451:39)
    at /node_modules/recoil-nexus/src/RecoilNexus.tsx:15:77
    at /node_modules/recoil/cjs/index.js:6114:22
    at /node_modules/recoil/cjs/index.js:3477:7
@luisanton-io
Copy link
Owner

Hi, it looks like the error is happening on useRecoilCallback, apparently when first invoked it can't find the context.
Which versions of Recoil and Recoil Nexus are you using?

@Kamahl19
Copy link
Author

@luisanton-io Thanks for getting back to me. I use the latest recoil and latest nexus

@luisanton-io
Copy link
Owner

Could be similar to this?

@Kamahl19
Copy link
Author

@RobinClowers
Copy link

Weird, I also ran into this when migrating from jest to vitest. I'm not at all sure what would cause this, I have a recoil root in my test, and it worked fine under jest. The only thing I can think is that I'm also migrating my package to ESM at the same time, probably something about loading this package (which appears to be commonjs) in an ESM package is somehow broken.

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

3 participants