React Scroll on Navigate
Scroll to top automatically when the route changes. Works well with React Router and other similar tools.
See the React Router guide for more details.
Usage
Manually, passing in your router's location
prop:
import ScrollToTopOnNavigate from 'react-scroll-on-navigate'; <div ="MyApp"> <ScrollToTopOnNavigate = /> ...</div>
Or, using a decorator if you prefer:
import ScrollToTopOnNavigate as ScrollToTopWithoutRouter from 'lsr-lib';import withRouter from 'react-router'; const ScrollToTopOnNavigate = ; <div ="MyApp"> <ScrollToTopOnNavigate /> ...</div>