Skip to content

Commit

Permalink
Update query parsing example
Browse files Browse the repository at this point in the history
  • Loading branch information
mjackson committed Oct 23, 2021
1 parent f60a506 commit 95596d3
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions examples/custom-query-parsing/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,10 @@ function useQueryParam<T>(
let value = React.useMemo(() => JSURL.parse(paramValue), [paramValue]);

let setValue = React.useCallback(
(newQuery: T, options?: NavigateOptions) => {
setSearchParams(
{
...searchParams,
[key]: JSURL.stringify(newQuery)
},
options
);
(newValue: T, options?: NavigateOptions) => {
let newSearchParams = new URLSearchParams(searchParams);
newSearchParams.set(key, JSURL.stringify(newValue));
setSearchParams(newSearchParams, options);
},
[key, searchParams, setSearchParams]
);
Expand Down

0 comments on commit 95596d3

Please sign in to comment.