Skip to content

Commit

Permalink
fix: handle case when router query is empty (not ready)
Browse files Browse the repository at this point in the history
  • Loading branch information
wyattjoh committed Oct 23, 2022
1 parent 24e6de8 commit 8e1b754
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/next/client/components/navigation.ts
Expand Up @@ -108,6 +108,10 @@ export function useSearchParams() {
// To support migration from pages to app, this adds a workaround that'll
// support the pages router here too.
if (router) {
if (!router.isReady) {
return new ReadonlyURLSearchParams(new URLSearchParams())
}

return new ReadonlyURLSearchParams(
parsedURLQueryToURLSearchParams(router.query)
)
Expand Down

0 comments on commit 8e1b754

Please sign in to comment.