We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When I use NextJS router query param the data fetched from SWR seemed to "randomly" be undefined. But when I change to
const id = typeof window !== 'undefined' ? window.location.pathname.split('/')[2] : ''
instead of
const router = useRouter() const { id } = router.query
The problem just goes away! Any idea why this is happening?
This is the link to my repo https://github.com/programming-in-th/programming.in.th The fetching is located in /src/pages/tasks/[id].tsx
PS. I see that example doesn't use query param either but use window.location.pathname slicing instead.
The text was updated successfully, but these errors were encountered:
Yeah, this is a Next.js behavior actually. To match the hydration (or pre-rendered) result, query will be empty at the beginning:
query
https://nextjs.org/docs#dynamic-routing
Sorry, something went wrong.
No branches or pull requests
When I use NextJS router query param the data fetched from SWR seemed to "randomly" be undefined. But when I change to
const id = typeof window !== 'undefined' ? window.location.pathname.split('/')[2] : ''
instead of
The problem just goes away! Any idea why this is happening?
This is the link to my repo https://github.com/programming-in-th/programming.in.th
The fetching is located in /src/pages/tasks/[id].tsx
PS. I see that example doesn't use query param either but use window.location.pathname slicing instead.
The text was updated successfully, but these errors were encountered: