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

Next.js 13, Dynamic Loading, and RTK Query #3156

Closed
littlejon opened this issue Feb 4, 2023 · 2 comments
Closed

Next.js 13, Dynamic Loading, and RTK Query #3156

littlejon opened this issue Feb 4, 2023 · 2 comments

Comments

@littlejon
Copy link

I have had this issue since Next.js 13 was released (but haven't had the chance to find a minimal reproduction until now).

image

Reproduction repo: https://github.com/littlejon/next13-rtk-dynamicimport-issue

Pages that contains lazy loaded component by next/dynamic, and using the React useQuery hook will throw the error.

This appears to be related to the isLoading property paired with the changes from React 18 and it is causing the fault to appear even when it isn't used in the component.

Page Setup Status
/failing Lazy Loaded Component, and RTK Hook
/failing2 Lazy Loaded Component, and RTK Hook with selectFromResult (contains isLoading)
/working Lazy Loaded Component, and RTK Hook with selectFromResult (excluding isLoading)
/working2 No Lazy Loaded Component, and RTK Hook
/working3 Lazy Loaded Component ({ ssr: false }), and RTK Hook

I can confirm that all of the above use cases work with Next.js 12.

@littlejon
Copy link
Author

I'm just doing some further testing within my project codebase by removing isLoading from my hooks and the issue presents itself sporadically, there is a race condition at play here by the looks of it. I'm going to try some profiling tools to see if I can find a source.

@littlejon
Copy link
Author

This problem has been fixed in vercel/next.js#45565 (next@13.1.7-canary.5)

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

1 participant