aboutsummaryrefslogtreecommitdiff
path: root/src/containers/Page/Page.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/containers/Page/Page.tsx')
-rw-r--r--src/containers/Page/Page.tsx13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/containers/Page/Page.tsx b/src/containers/Page/Page.tsx
index 7df62cd..b7e1938 100644
--- a/src/containers/Page/Page.tsx
+++ b/src/containers/Page/Page.tsx
@@ -5,11 +5,14 @@ import { SnackbarProvider } from 'notistack';
import { ErrorBoundary } from 'react-error-boundary';
import { useHistory } from 'react-router-dom';
-import Router from './Router';
+import Router, { LocationState } from './Router';
import DynoWaiter from './DynoWaiter';
import Loading from '../../components/Loading/Loading';
import EmptyState from '../../components/EmptyState/EmptyState';
+interface HistoryChange {
+ state?: LocationState | null;
+}
const useStyles = makeStyles(theme => ({
root: {
@@ -32,11 +35,9 @@ const Page: React.FC = () => {
const history = useHistory();
const isMobile = useMediaQuery(theme.breakpoints.down('sm'));
- useEffect(() => {
- return history.listen(() => {
- window.scrollTo(0, 0);
- });
- }, [history]);
+ useEffect(() => history.listen((update: HistoryChange) => {
+ if (!update.state?.background) window.scrollTo(0, 0);
+ }), [history]);
return (
<SnackbarProvider