Saves a feed page's state, with its scroll position, as the page is left, and restores the position when the page is back.
f
useScrollRestore(): void
scrollY: number | null | undefined,
loaded: boolean
Scrolls the window to scrollY once loaded, and never again, before
paint so that the restored page doesn't flash at the top. Feed pages pass
useFeedCache's cached?.scrollY, which is undefined when nothing was
restored.
f
useScrollSave(): void
enabled: boolean,
onSave: (scrollY: number) => void
Calls onSave(scrollY) when the component unmounts or the tab is hidden
(pagehide), while enabled. Feed pages pass enabled once their feed is
loaded, and an onSave that calls useFeedCache's saveState.
Usage
import * as mod from "src/hooks/feed/useScrollSave.ts";