0.4.1 • Published 4 years ago
@jmdc-rehooks/use-restore-scroll-position v0.4.1
use-restore-scroll-position
Restore previous scroll position after reloading the page.
Usage
import useRestoreScrollPosition from '@jmdc-rehooks/use-restore-scroll-position
const Component = () => {
const ref = React.useRef(null)
useRestoreScrollPosition({ target: ref, scrollBehavior: 'auto' })
return <div ref={ref}>Content</div>
}
Options
target: RefObject<HTMLElement>
RefObject
of the target scroll container.
scrollBehavior: "smooth" | "auto"
Scroll behavior.
disable: boolean
Disable restoring scroll position.