react-router-scroll-behavior
Scroll behaviors for use with react-router. Based on scroll-behavior.
What's the problem of scroll-behavior
?
scroll-behavior
and react-router
are all rely on history
and listen the location change. But react-router
route components by using setState
which is asynchronous. So that scroll behaviors may happen before routing finished.
Installation
$ npm i react-router-scroll-behavior --save
Usage
// Render `Router` with RouterScrollContext