showing results for - "handling scrolling on react router transitions"
Elisa
01 May 2018
1import { useEffect } from 'react';
2import { withRouter } from 'react-router-dom';
3
4function ScrollToTop({ history }) {
5  useEffect(() => {
6    const unlisten = history.listen(() => {
7      window.scrollTo(0, 0);
8    });
9    return () => {
10      unlisten();
11    }
12  }, []);
13
14  return (null);
15}
16
17export default withRouter(ScrollToTop);
18
queries leading to this page
when switching pages in react need to start at topreact router scroll to top on backreact router page not scrollablescroll to top to every page react nativepage scroll react using linkreact router scroll to top on every transitionreact when clicking on a link 2c go to top of pagereact redirects to the page and scrolls downreact router dom force not scroll on change routereact scroll doesn scroll to tophow to scroll to componet with router in reactstart page at the top after routing reactreact router changing page dosent reset scroolhow to make sure top of page on link react mobilereact router reset scroll positionwhen navigating through pages scroll to the top reacthow to push on top of the page when i change location reactreact scroll doesnt scroll to topreact route is not opening from top pagehow to make the screen to load from top on routing in reactreact router scroll contextconnected react router scroll to toptop of page when routing reactreact router scroll down on every transitionscrolltotop react router onclickhow to change position react router in reactjshow to get window scroll position in react in that route only react link to scroll positionreact redirected to the top of the pagereact router doesn 27t scroll to topreact scroll to top on page changereact history push to top of pagereact switch to the top of other routerhow to import react router dom and react scroll togetheropen 3clink 3e at top of page react router v5pop to top with react router domreact history scroll to topreact router dom 5 sub routes not scrollreact link changeing page same scrol pasition need topscroll to top of the page when routed to a new route reactscroll to top if page changed reactreact on route change scroll topreact typescript scroll to topreact does not scroll to top whne page changesreact router always rendering top of pageopen 26lt 3blink 26gt 3b at top of page react router v5router not going to top of pagejump to top of the page without aniumation aftet routing reactreact router dom link scholl positionreact history push and scroll to elementreact navigation scroll to top in every routereact router reset scrollreact router scroll to topreact scroll to 0 on new route changehow to change react router position reactjsreact router route page loads at the bottom of the pagereact router scroll to top on route changereac router not scrollingpage doesn 27t scroll to top while navigate to another page in reactpage always defaulting to top on 1st render react routerreact router move to another pages topreact connected router scroll to topswitching nav reacjs automatically scroll upreact router dom scroll to top on route changeusing react scroll to route to another pagereact scroll doesn 27t scroll after route changereact router scrool to topreact scroll to top on route changereact scroll to top on pushmake sure a page loads at the top reactscroll react routerpage scrolling effects menu reactreact scroll top on route changescroll up when neviragte react trouterreact go top of the page when page changesreact router link go to top of new componentwhy does router go to top of page on 1st renderlink react router dom top of pagereact how to go up the page when changing routereactjs switch change scorllreact scroll to 0 before route cchangeby clicking on the link go to the top react router domchange pages when scroll reactjsscrollto after link reactreact router scroll to top without componentload top on link reactpage is not scrolling in react routerreact scroll not changed when page changedreact page not starting from topscroll to top react routerhistory goback scroll to top pagehow to scrool to top when clicking on react linkreact link to always go to top of pagereact jump to half pagego up in the page react routerreact router with scrollreact redirect to the top of the pagehow to reset browser window to top reacthandling scrolling on react router transitions