Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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);

Comment

PREVIOUS NEXT
Code Example
Javascript :: Webpack: How to compile, write on disk and serve static content (js/css/html/assets) using webpack-dev-server 
Javascript :: ES5 Assigning Variables to Object Properties 
Javascript :: Cannot GET /public/staffRegister in node.js 
Javascript :: string in vue.js 
Javascript :: intialize vue select using cdn 
Javascript :: Remove the warning for setState on unmounted components in React 
Javascript :: error code ELIFECYCLE REACTJs 
Javascript :: dédoublé un tableau et supprimé les doublons 
Javascript :: upload file javascript mdn 
Javascript :: how to add array of object in class in javascript 
Javascript :: node string for euro sign 
Javascript :: early exit js 
Javascript :: convert jquery hide function to pure javascript code 
Javascript :: check if date is valid js 
Javascript :: node.js how to install a custom version of packgage 
Javascript :: vscode php format brackets 
Javascript :: react-native-error-check-the-render-method-of-app 
Javascript :: open each image on its own modal page 
Javascript :: discord.js send dm to specific user 
Javascript :: change env location react 
Javascript :: how to combine folder for render in express js 
Javascript :: react native bottom sheet example 
Javascript :: React uses _____________ syntax. 
Javascript :: python faker json 
Javascript :: on second click javascript 
Javascript :: Scotch.io - Create a CRUD App with Node and MongoDB 1 Getting Started 
Javascript :: SHOPIFY CUSTOMER WITH REGISTRATION 
Javascript :: react router v6 wrapped routes in separate files 
Javascript :: public url react for serving django static in production 
Javascript :: This shorthand syntax is also known as the concise method syntax. It’s valid to have spaces in the property name. 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =