Skip to content

Commit

Permalink
fix: Return the router update method to await it
Browse files Browse the repository at this point in the history
Solves issues with setting multiple query parameters
in one go: the location.search needs to
be updated before the next update can
pick it up and append to it, otherwise
updated values are erased.

This is something useQueryStates is bound to solve at some point.

See #277 (comment)
  • Loading branch information
franky47 committed Jan 27, 2022
1 parent acb97d0 commit 205c6ab
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/useQueryState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export function useQueryState<T = string>(
key: string,
{
history = 'replace',
parse = x => (x as unknown) as T,
parse = x => x as unknown as T,
serialize = x => `${x}`,
defaultValue
}: Partial<UseQueryStateOptions<T>> = {}
Expand Down Expand Up @@ -155,7 +155,7 @@ export function useQueryState<T = string>(
const [asPath] = router.asPath.split(/\?|#/, 1)
const search = query.toString()
const hash = window.location.hash
updateUrl?.call(
return updateUrl?.call(
router,
{
pathname: router.pathname,
Expand Down

0 comments on commit 205c6ab

Please sign in to comment.