mirror of
https://github.com/Unleash/unleash.git
synced 2025-04-10 01:16:39 +02:00
This is rather big change to react-router and required a lot of rewrites. Mostly followed this guide: https://github.com/ReactTraining/react-router/blob/master/packages/react-router/docs/guides/migrating.md
22 lines
483 B
JavaScript
22 lines
483 B
JavaScript
import { Component } from 'react';
|
|
import { withRouter } from 'react-router-dom';
|
|
import PropTypes from 'prop-types';
|
|
|
|
class ScrollToTop extends Component {
|
|
static propTypes = {
|
|
location: PropTypes.object.isRequired,
|
|
};
|
|
|
|
componentDidUpdate(prevProps) {
|
|
if (this.props.location !== prevProps.location) {
|
|
window.scrollTo(0, 0);
|
|
}
|
|
}
|
|
|
|
render() {
|
|
return this.props.children;
|
|
}
|
|
}
|
|
|
|
export default withRouter(ScrollToTop);
|