File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed
packages/react-router-dom Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -1255,13 +1255,11 @@ function useScrollRestoration({
12551255 // Enable scroll restoration in the router
12561256 // eslint-disable-next-line react-hooks/rules-of-hooks
12571257 React . useLayoutEffect ( ( ) => {
1258- let disableScrollRestoration = router ?. enableScrollRestoration (
1259- savedScrollPositions ,
1260- ( ) => window . scrollY ,
1261- getKey
1258+ let getKeyWithoutBasename : GetScrollRestorationKeyFunction | undefined =
1259+ getKey && basename !== "/"
12621260 ? ( location , matches ) =>
12631261 getKey (
1264- // Strip the basename to match useLocation
1262+ // Strip the basename to match useLocation()
12651263 {
12661264 ...location ,
12671265 pathname :
@@ -1270,7 +1268,11 @@ function useScrollRestoration({
12701268 } ,
12711269 matches
12721270 )
1273- : undefined
1271+ : getKey ;
1272+ let disableScrollRestoration = router ?. enableScrollRestoration (
1273+ savedScrollPositions ,
1274+ ( ) => window . scrollY ,
1275+ getKeyWithoutBasename
12741276 ) ;
12751277 return ( ) => disableScrollRestoration && disableScrollRestoration ( ) ;
12761278 } , [ router , basename , getKey ] ) ;
You can’t perform that action at this time.
0 commit comments