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 :: javascript for loop[ 
Javascript :: date picker javascript not working 
Javascript :: mongoose update 
Javascript :: how to find max number in array javascript 
Javascript :: arrow functions in javascript 
Javascript :: node js documentation 
Javascript :: nestjs custom error class validator 
Javascript :: gltfjsx 
Javascript :: how to run socket.io server 
Javascript :: Discord.js Get A Bot To Join A Music Chanel 
Javascript :: string methods javascript 
Javascript :: js difference between two arrays of objects 
Javascript :: take from your discord bot dms discord js 
Javascript :: how to pass headers in axios 
Javascript :: redux saga fetch api 
Javascript :: on button click show collapse div jquery 
Javascript :: convert nested json to csv python 
Javascript :: react setstate in another component 
Javascript :: how to remove last element from array in javascript 
Javascript :: external css not working in jsp 
Javascript :: mail 
Javascript :: javascript check table not empty 
Javascript :: flatlist only rendering 10 items 
Javascript :: js html editor 
Javascript :: salvar no localStorage react 
Javascript :: javascript decimals without rounding 
Javascript :: how can hide link from inspect element 
Javascript :: then and catch in promise 
Javascript :: for i in range vue js 
Javascript :: how to get variable from url in javascript 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =