Skip to content

Latest commit

 

History

History
31 lines (22 loc) · 680 Bytes

README.md

File metadata and controls

31 lines (22 loc) · 680 Bytes

Scroll to Top on Navigate for React Router

Creates automatic scroll-to-top behaviour when the route changes. The package also preserves previous pages' scroll position upon navigating back with the Back button.

Works with the latest version of React Router

Install

npm install scroll-to-top-react-router

Import

import ScrollToTop from 'scroll-to-top-react-router'

Usage

Use inside the Router component, for example as below in App.js:

<Router>
  <ScrollToTop />
  <Routes>
    <Route path="/" exact component={Home} />
    <Route path="/about" exact component={About} />
  </Routes>
</Router>