-
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
Next.js router.isReady never set to true on custom 404 page #35990
Comments
Additionally, after landing on a 404 page the |
I had the same issue because |
I am able to reproduce this bug the way @iiroj described. |
I found out that |
I can confirm this works, I needed access to |
@vixeven #35990 (comment) links to it :) But here you go: https://nextjs.org/docs/advanced-features/custom-error-page#reusing-the-built-in-error-page |
Previously, query parameters were not available on 404 pages because calling the router methods would change the pathname in the browser. This change adds support for the query to update for those pages without updating the path to include the basePath. This additionally narrows some Typescript types that were previous set to `any` which highlighted some type errors that were corrected. Fixes: #35990 Co-authored-by: JJ Kasper <[email protected]>
Previously, query parameters were not available on 404 pages because calling the router methods would change the pathname in the browser. This change adds support for the query to update for those pages without updating the path to include the basePath. This additionally narrows some Typescript types that were previous set to `any` which highlighted some type errors that were corrected. Fixes: #35990 Co-authored-by: JJ Kasper <[email protected]>
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
What browser are you using? (if relevant)
Safari 15.4 (17613.1.17.1.13)
How are you deploying your application? (if relevant)
next dev
Describe the Bug
The Next.js router object contains a boolean value
router.isReady
, which according to docs indicates:We are using this in a
withSSRLoadingIndicator
HoC that checks inside anuseEffect
hook that if the router is ready, render page component, and else render a full-screen loading indicator. This allows us to deploy certain pages as small static files, which only load client-side, while other pages can use the fullgetServerSideProps
method and render what they need directly. With the HoC, we don't have to check if therouter.query
object is populated, because the page component will receive the data on its first render (because thenrouter.isReady = true
).This HoC works nicely on all other pages expect our custom 404 page, and after a bit of debugging it seems that the Router instance simply never sets
router.isReady = true
.Expected Behavior
I would expect the custom 404 to also receive
router.isReady = true
on the client-side.To Reproduce
Create a Next.js page
src/pages/index.js
with code like this:When opening the page in your browser, http://localhost:3000/, you will see:
Router is not ready
on the first renderRouter is ready
on the second renderCopy the same page component as
src/pages/404.js
, open http://localhost:3000/404, and you will instead see:Router is not ready
on the first renderThe text was updated successfully, but these errors were encountered: