Answers for "take site to top after clicking in react"

0

take site to top after clicking in react

import { useEffect } from "react";
    import { withRouter } from "react-router-dom";

    const ScrollToTop = ({ children, location: { pathname } }) => {
      useEffect(() => {
        window.scrollTo({
          top: 0,
          left: 0,
          behavior: "smooth"
        });
      }, [pathname]);

      return children || null;
    };

    export default withRouter(ScrollToTop);
Posted by: Guest on October-07-2021

Code answers related to "take site to top after clicking in react"

Code answers related to "Javascript"

Browse Popular Code Answers by Language