Skip to content

Commit

Permalink
Fix scroll restoration (fix #831)
Browse files Browse the repository at this point in the history
  • Loading branch information
martpie committed Feb 25, 2025
1 parent b59399a commit 12c08d4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/hooks/useScrollRestoration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function useScrollRestoration(
}, [target, key]);

useEffect(() => {
if (state === 'idle' && !init) {
if (state === 'idle' && !init && target != null) {
setInit(true);
target?.scrollTo(0, getScrollPosition(key));
}
Expand Down

0 comments on commit 12c08d4

Please sign in to comment.