-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Hooks not working in the loading
page
#44249
Comments
I think the loading behavior is a hard problem to solve Since nextjs uses streaming to show loading before the page has finished loading even JavaScript code. Because of that your loading page cannot be interactive because nextjs has to load the JS first, hydrate your page then run the client code. It cannot work when your user load the page first (full reload of the browser), but i think it could work between page transitions, since the JS has already been loaded. But i could also be wrong about page transitions and the loading page cannot be interactive 🤷🏾♂️. |
@reza-ebrahimi are you sure you are on the right issue ? |
dont know either how this is related but thanks for sharing the side effect of strict mode... i wondered why i have all these double calls in my code ;-) |
Any progress on this? i am having the same issue, i cannot run hooks in loading js, it works when i navigate to tother pages, but not when i first load the page |
I think it makes sense for hooks not to work, as the JavaScript needed to run the hook is still "loading", that's why the loading page exists |
The docs indicate that this should work https://nextjs.org/docs/app/api-reference/file-conventions/loading
But I am also having this problem -- when |
Likewise, I'm trying to create an animated loading spinner using react-spring, and failing on the loading.tsx page as no useEffect seems to be called. The root svg element is loaded, however, no updates occur to the documents state. |
Verify canary release
Provide environment information
brand new clean install of Next13
Which area(s) of Next.js are affected? (leave empty if unsure)
No response
Link to the code that reproduces this issue
local
To Reproduce
experimental: { appDir: true },
to thenext.config.js
filelayout.js
page.js
andloading.js
(the last one is the issue)Layout Code:
page code:
loading code:
Describe the Bug
I found this bug while creating a loading screen for my application, I was trying to use
anime.js
in the loading screen and then I noticed none of the hooks I defined where being called.despite that I was able to call my function
animateEverything
outside of everything, as I stated on the steps and it started to work (actually the animation was starting) but when I was trying to build I got an error like this:also another thing that I noticed was that if I put some functions with more logs in the code, they were appearing on the terminal instead of the chrome console. for example
loading code:
other things that I was testing is leaving the
loading.js
file as a server component and create another with the loader, then call it fromloading.js
but same behaviour.Expected Behavior
it should behave as a client component and use correctly the hooks without problems.
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
Vercel
The text was updated successfully, but these errors were encountered: