qotnews/webclient/src/ScrollToTop.js

17 lines
329 B
JavaScript
Raw Normal View History

import React from 'react';
2019-10-22 07:31:59 +00:00
import { withRouter } from 'react-router-dom';
class ScrollToTop extends React.Component {
componentDidUpdate(prevProps) {
if (this.props.location.pathname !== prevProps.location.pathname) {
window.scrollTo(0, 0);
}
}
render() {
return null;
}
}
export default withRouter(ScrollToTop);