Skip to content

Commit

Permalink
docs: fix ScrollRestoration getKey example (#9266)
Browse files Browse the repository at this point in the history
Co-authored-by: Tim Dorr <timdorr@users.noreply.github.com>
  • Loading branch information
GraxMonzo and timdorr committed Sep 15, 2022
1 parent 7520e78 commit 30c1b5c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions contributors.yml
Expand Up @@ -105,3 +105,4 @@
- xavier-lc
- xcsnowcity
- yuleicul
- GraxMonzo
6 changes: 3 additions & 3 deletions docs/components/scroll-restoration.md
Expand Up @@ -28,7 +28,7 @@ Optional prop that defines the key React Router should use to restore scroll pos

```tsx
<ScrollRestoration
getKey={({ location, matches }) => {
getKey={(location, matches) => {
// default behavior
return location.key;
}}
Expand Down Expand Up @@ -58,7 +58,7 @@ A solid product decision here is to keep the users scroll position on the home f

```tsx
<ScrollRestoration
getKey={({ location, matches }) => {
getKey={(location, matches) => {
return location.pathname;
}}
/>
Expand All @@ -68,7 +68,7 @@ Or you may want to only use the pathname for some paths, and use the normal beha

```tsx
<ScrollRestoration
getKey={({ location, matches }) => {
getKey={(location, matches) => {
const paths = ["/home", "/notifications"];
return paths.includes(location.pathname)
? // home and notifications restore by pathname
Expand Down

0 comments on commit 30c1b5c

Please sign in to comment.