Skip to content

Commit 5962a34

Browse files
committed
docs: update examples using getKey
1 parent 8d15bf8 commit 5962a34

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

docs/router/framework/react/guide/scroll-restoration.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ Falling in behind Remix's own Scroll Restoration APIs, you can also customize th
7171

7272
The `getKey` option receives the relevant `Location` state from TanStack Router and expects you to return a string to uniquely identify the scrollable measurements for that state.
7373

74-
The default `getKey` is `(location) => location.state.key!`, where `key` is the unique key generated for each entry in the history.
74+
The default `getKey` is `(location) => location.state.__TSR_key!`, where `__TSR_key` is the unique key generated for each entry in the history.
75+
76+
> Older versions, prior to `v1.121.34`, used `state.key` as the default key, but this has been deprecated in favor of `state.__TSR_key`. For now, `location.state.key` will still be available for compatibility, but it will be removed in the next major version.
7577
7678
## Examples
7779

@@ -95,7 +97,7 @@ const router = createRouter({
9597
const paths = ['/', '/chat']
9698
return paths.includes(location.pathname)
9799
? location.pathname
98-
: location.state.key!
100+
: location.state.__TSR_key!
99101
},
100102
})
101103
```

0 commit comments

Comments
 (0)