Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

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





```