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

Devtools error/crashing with NextJS 14.1 #127

Closed
mnpqraven opened this issue Feb 26, 2024 · 8 comments
Closed

Devtools error/crashing with NextJS 14.1 #127

mnpqraven opened this issue Feb 26, 2024 · 8 comments

Comments

@mnpqraven
Copy link

mnpqraven commented Feb 26, 2024

NextJS version ^14.1 will break devtools with the following error when you click on the atom viewer
image

Here is the minimal reproducible repo: https://github.com/mnpqraven/jotai-repro
A workaround for now is to use 14.0.x, I'm using 14.0.2 for my projects and they seem to work fine

@arjunvegda
Copy link
Member

Thanks a lot for the repro!

Removing swcPlugins from the next.config.mjs gets rid of the error within the DevTools. I still see (0 , jotai__WEBPACK_IMPORTED_MODULE_2__.useAtomValue) is not a function 🤔

- swcPlugins: [
-   ["@swc-jotai/debug-label", {}],
-   ["@swc-jotai/react-refresh", {}],
- ],
image

@arjunvegda
Copy link
Member

Adding 'use client'; at the top of Page.tsx (on top of removing swcPlugins from next.config.mjs) fixes the issue. I'm not sure if this is ideal but should unblock you for now

(You might want to delete the .next folder after making these changes.)

image

@huraim
Copy link

huraim commented Feb 27, 2024

@arjunvegda

Thank you!
I tried applying as you mentioned, and it seems to work.
I still want to use version 14.1 without downgrading.
It's a shame that I can't use the features of https://jotai.org/docs/tools/swc...
For now, I'll have to apply debugLabel directly.

1. Remove swcPlugins
2. Remove .next
3. Restart
4. Write `debugLabel`

@huraim
Copy link

huraim commented Feb 27, 2024

Instead of adding 'use client'; at the top of Page.tsx,
I recommend creating a separate JotaiDevtool component
and adding 'use client'; at the top of the JotaiDevtool.tsx.

@arjunvegda
Copy link
Member

For now, I'll have to apply debugLabel directly.

@huraim - could you try using our babel plugins?

@huraim
Copy link

huraim commented Feb 28, 2024

@arjunvegda - I was using swc before the migration, so I missed that. I'll try applying babel. Thank you for the suggestion.

@mnpqraven
Copy link
Author

mnpqraven commented Feb 29, 2024

hmm I'm trying to apply said changes to my current project to bump next to 14.1 and while the errors are gone, the devtools are not detecting any atom (even though it does in the reproduction repo, weird)

EDIT: now it works without any changes, idk what happens..
EDIT2: it's no longer working again, I think this might have something to do with possibly the provider or NextJS, i'll try to reproduce this

@arjunvegda
Copy link
Member

The latest version of NextJS appears to have fixed this issue. Please feel free to reopen if you're still experiencing this problem

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