Skip to content

Commit

Permalink
fix: do not cause SSR in dynamic paths
Browse files Browse the repository at this point in the history
  • Loading branch information
MRobertEvers authored and franky47 committed Oct 15, 2020
1 parent 4c44f9c commit 84e70bb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ coverage/
yarn-error.log
# Docker containers with persistance
.volumes/
package-lock.json
18 changes: 13 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,19 @@ export function useQueryState<T = string>(
// router.pathname includes dynamic route keys, rather than the route itself,
// e.g. /views/[view] rather than /views/my-view
const [asPath] = router.asPath.split(/\?|#/, 1)
updateUrl?.call(router, {
pathname: asPath,
hash: window.location.hash,
search: query.toString()
})
updateUrl?.call(
router,
{
pathname: router.pathname,
hash: window.location.hash,
search: query.toString()
},
{
pathname: asPath,
hash: window.location.hash,
search: query.toString()
}
)
},
[key, updateUrl]
)
Expand Down

0 comments on commit 84e70bb

Please sign in to comment.