Files
shlink-web-client/src/common/ScrollToTop.js
2018-08-05 11:20:09 +02:00

23 lines
421 B
JavaScript

import React from 'react';
import { withRouter } from 'react-router-dom'
export class ScrollToTop extends React.Component {
componentDidUpdate(prevProps) {
const { location, window } = this.props;
if (location !== prevProps.location) {
window.scrollTo(0, 0)
}
}
render() {
return this.props.children;
}
}
ScrollToTop.defaultProps = {
window
};
export default withRouter(ScrollToTop);