aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-08-13 23:55:35 +0300
committereug-vs <eug-vs@keemail.me>2020-08-13 23:55:35 +0300
commitd7aba191cdfbf6f2f5e35bcaa94e011fafcde3dc (patch)
tree3f2302ff9a80d9ee0b87f508304d675ad9f2edfe /src
parent474dd922ac0512f1e0f64c145e9f76d2b10a1ba5 (diff)
downloadwhich-ui-d7aba191cdfbf6f2f5e35bcaa94e011fafcde3dc.tar.gz
feat: scroll to top on redirects
Diffstat (limited to 'src')
-rw-r--r--src/containers/Page/Page.tsx11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/containers/Page/Page.tsx b/src/containers/Page/Page.tsx
index 848ca1d..c876dae 100644
--- a/src/containers/Page/Page.tsx
+++ b/src/containers/Page/Page.tsx
@@ -1,8 +1,8 @@
-import React, { Suspense } from 'react';
+import React, { Suspense, useEffect } from 'react';
import { makeStyles, useTheme } from '@material-ui/core/styles';
import { useMediaQuery } from '@material-ui/core';
import { SnackbarProvider } from 'notistack';
-import { Switch, Route } from 'react-router-dom';
+import { Switch, Route, useHistory } from 'react-router-dom';
import Loading from '../../components/Loading/Loading';
const Profile = React.lazy(() => import('../Profile/Profile'));
@@ -29,8 +29,15 @@ const useStyles = makeStyles(theme => ({
const Page: React.FC = () => {
const classes = useStyles();
const theme = useTheme();
+ const history = useHistory();
const isMobile = useMediaQuery(theme.breakpoints.down('sm'));
+ useEffect(() => {
+ return history.listen(() => {
+ window.scrollTo(0, 0);
+ });
+ }, [history])
+
return (
<SnackbarProvider
preventDuplicate