Getting Starteduse-intersection-observeruse-mouse-positionuse-on-hoveruse-scroll-directionuse-scroll-progressuse-scroll-to-topuse-window-size
use-scroll-to-top
Description
Our hook
import React from "react";import { useScrollToTop } from "react-hooks-lab";const ScrollToTop = () => {useScrollToTop();useEffect(() => {// your stuff}, []);};
If you need a react-router scroll restoration just do it like this
import React from "react";const ScrollToTop = ({ children, location: { pathname } }) => {useEffect(() => {window.scrollTo(0, 0);}, [pathname]);return children || null;};export default withRouter(ScrollToTop);