Skip to content

Commit

Permalink
use shallow routing for URL persistence. (#139)
Browse files Browse the repository at this point in the history
* Expose shallow routing as a prop.

* Default shallow to true.

* Shallow push is always enabled.

* Removed shallow from README.md
  • Loading branch information
lucianojd committed Nov 7, 2022
1 parent 547b958 commit d893a1e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ See [atomFamily](https://recoiljs.org/docs/api-reference/utils/atomFamily) for m

#### Return

A function which takes `paramter` that map to an atom, and its `initialValue`.
A function which takes `parameter` that map to an atom, and its `initialValue`.

#### Example

Expand Down
10 changes: 8 additions & 2 deletions src/url/useSyncURLNext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,15 @@ export function useSyncURLNext(): Partial<
}, [])

const browserInterface: BrowserInterface = {
replaceURL: useCallback((url: string) => replace(url), [replace]),
replaceURL: useCallback(
(url: string) => replace(url, undefined, { shallow: true }),
[replace]
),

pushURL: useCallback((url: string) => push(url), [push]),
pushURL: useCallback(
(url: string) => push(url, undefined, { shallow: true }),
[push]
),

getURL: useCallback(() => {
const url = new URL(
Expand Down

0 comments on commit d893a1e

Please sign in to comment.