react-router-scroll-to-top
v1.2.1
Published
React component that scrolls to the top of a page when the current location gets changed
Downloads
1,052
Maintainers
Readme
react-router-scroll-to-top
ScrollToTop is a React component that scrolls to the top of a page when the current location gets changed. Since React Router doesn't provide out-of-the-box support for scroll restoration due to browsers having started handling it on their own, this package implements a component for scrolling to the top manually as it is given in React Router docs.
Usage
npm install react-router-scroll-to-top
import { ScrollToTop } from 'react-router-scroll-to-top';
const App = () => (
<BrowserRouter>
<ScrollToTop />
<Routes>{/* routes */}</Routes>
</BrowserRouter>
);
Read the documentation for more details. You can also play with a demo.
Support
If you like this package and want to support it, you can do it on Patreon