Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

react scroll on top while transition

import ScrollToTop from "./scrollToTop";

function App() {
  return (
    <Router>
      <ScrollToTop />
      <App />
    </Router>
  );
}
Comment

react scroll on top while transition

import ScrollToTop from "./scrollToTop";

ReactDOM.render(
    <BrowserRouter>
        <ScrollToTop />
        <App />
    </BrowserRouter>
    document.getElementById("root")
);
Comment

react scroll on top while transition

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

export default function ScrollToTop() {
  const { pathname } = useLocation();

  useEffect(() => {
    window.scrollTo(0, 0);
  }, [pathname]);

  return null;
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: nuxt redirect traffic from http to https 
Javascript :: hnazmul hassan 
Javascript :: jquery scroll when object appear on screen make animation 
Javascript :: mongoose connect url 
Javascript :: how to get the nth child of dom js 
Javascript :: js get domain 
Javascript :: split string into equal chunks javascript 
Javascript :: string array to number array javascript 
Javascript :: convert object to json javascript 
Javascript :: require() of ES modules is not supported when importing node-fetch 
Javascript :: how to add an image using jquery 
Javascript :: how to read write object to localStorage in js 
Javascript :: javascript call function on click give element id 
Javascript :: get value by id js 
Javascript :: js bmi calculator 
Javascript :: axios pass params 
Javascript :: asyncstorage react native 
Javascript :: how to creat a function 
Javascript :: javascript replace string at position 
Javascript :: javascript redirect to 
Javascript :: get a element using name in jquery 
Javascript :: how to use await to console 
Javascript :: how to check if a tag has any chidren 
Javascript :: javascript remove first space in string 
Javascript :: center an element react native 
Javascript :: File is a CommonJS; it may be converted to an ES6 module 
Javascript :: store array in localstorage 
Javascript :: html add new line in js alert 
Javascript :: how to take a input video 
Javascript :: loopback upsert with where 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =