Revert ScrollToTop component back to class-based

This commit is contained in:
2025-12-02 17:02:03 +00:00
parent bf3e6bbc28
commit 4c9d5eede1

View File

@@ -1,10 +1,14 @@
import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';
import React from 'react';
import { withRouter } from 'react-router-dom';
function ScrollToTop() {
const { pathname } = useLocation();
class ScrollToTop extends React.Component {
componentDidUpdate(prevProps) {
//console.log(this.props.location.pathname, prevProps.location.pathname);
if (this.props.location.pathname === prevProps.location.pathname) {
return;
}
useEffect(() => {
if (localStorage.getItem('scrollLock') === 'True') {
localStorage.setItem('scrollLock', 'False');
return;
@@ -12,9 +16,11 @@ function ScrollToTop() {
window.scrollTo(0, 0);
document.body.scrollTop = 0;
}, [pathname]);
return null;
}
export default ScrollToTop;
render() {
return null;
}
}
export default withRouter(ScrollToTop);