redux-router-scroll-restoration
Version:
Middleware for restoration scroll position after changing page
33 lines (24 loc) • 674 B
Markdown
# Scroll restoration
Simple middleware for scroll restoration.
## Install
`npm i -S redux-router-scroll-restoration`
or
`yarn add redux-router-scroll-restoration`
## Usage
```javascript
import { createStore, applyMiddleware } from 'redux'
import { routerMiddleware } from 'react-router-redux'
import createHistory from 'history/createBrowserHistory'
import scrollRestorationMiddleware from 'redux-router-scroll-restoration'
import rootReducer from './reducer'
const history = createHistory()
const initialState = {}
const store = createStore(
rootReducer,
initialState,
applyMiddleware(
routerMiddleware(history),
scrollRestorationMiddleware
)
)
```