Fixed scroll position across the app (#2375)

* fixed scroll across the app

* changes file
This commit is contained in:
Martavis Parker 2021-10-05 09:04:24 -07:00 committed by GitHub
parent afc8bdd093
commit 53f82b8e28
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View file

@ -0,0 +1 @@
- Fixed scroll position when navigating to different pages

View file

@ -11,6 +11,7 @@ import { authToken } from "utilities/local";
interface IAppProps {
children: JSX.Element;
location: any; // no type in react-router v3
}
interface IRootState {
@ -22,7 +23,7 @@ interface IRootState {
};
}
export const AuthenticatedRoutes = ({ children }: IAppProps) => {
export const AuthenticatedRoutes = ({ children, location }: IAppProps) => {
const dispatch = useDispatch();
const { user } = useSelector((state: IRootState) => state.auth);
const { locationBeforeTransitions } = useSelector(
@ -64,6 +65,10 @@ export const AuthenticatedRoutes = ({ children }: IAppProps) => {
}
}, [user]);
useDeepEffect(() => {
window.scrollTo(0, 0);
}, [location]);
if (!user) {
return false;
}