Saves a feed page's state, with its scroll position, as the page is left, and restores the position when the page is back.

Functions

f
useScrollRestore(
scrollY: number | null | undefined,
loaded: boolean
): void

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(
enabled: boolean,
onSave: (scrollY: number) => void
): 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.