0.1.3 • Published 6 years ago

react-scroll-on-navigate v0.1.3

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

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 className="MyApp">
  <ScrollToTopOnNavigate location={location} />
  ...
</div>

Or, using a decorator if you prefer:

import { ScrollToTopOnNavigate as ScrollToTopWithoutRouter } from 'lsr-lib';
import { withRouter } from 'react-router';

const ScrollToTopOnNavigate = withRouter(ScrollToTopWithoutRouter);

<div className="MyApp">
  <ScrollToTopOnNavigate />
  ...
</div>