2019-08-30 06:22:26 +00:00
|
|
|
import React from 'react';
|
2019-10-22 07:31:59 +00:00
|
|
|
import { withRouter } from 'react-router-dom';
|
2019-08-30 06:22:26 +00:00
|
|
|
|
|
|
|
class ScrollToTop extends React.Component {
|
|
|
|
componentDidUpdate(prevProps) {
|
2020-01-04 23:36:24 +00:00
|
|
|
//console.log(this.props.location.pathname, prevProps.location.pathname);
|
|
|
|
|
|
|
|
if (this.props.location.pathname === prevProps.location.pathname) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (localStorage.getItem('scrollLock') === 'True') {
|
|
|
|
localStorage.setItem('scrollLock', 'False');
|
|
|
|
return;
|
2019-08-30 06:22:26 +00:00
|
|
|
}
|
2020-01-04 23:36:24 +00:00
|
|
|
|
|
|
|
window.scrollTo(0, 0);
|
2019-08-30 06:22:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default withRouter(ScrollToTop);
|