Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/llleeeaaannn/scroll-to-top-react-router
NPM Package to enable scroll to top on navigate for React Router DOM while maintaining scroll for previous pages on use of Back button.
https://github.com/llleeeaaannn/scroll-to-top-react-router
npm react react-router
Last synced: 22 days ago
JSON representation
NPM Package to enable scroll to top on navigate for React Router DOM while maintaining scroll for previous pages on use of Back button.
- Host: GitHub
- URL: https://github.com/llleeeaaannn/scroll-to-top-react-router
- Owner: llleeeaaannn
- License: mit
- Created: 2023-01-26T17:29:16.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-28T14:32:40.000Z (almost 2 years ago)
- Last Synced: 2024-09-14T11:11:41.859Z (about 2 months ago)
- Topics: npm, react, react-router
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/scroll-to-top-react-router
- Size: 1.28 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://reactrouter.com/en/main)
## Install
```npm
npm install scroll-to-top-react-router
```## Import
```js
import ScrollToTop from 'scroll-to-top-react-router'
```## Usage
Use inside the Router component, for example as below in App.js:
```jsx
```