diff options
author | Eugene Sokolov <eug-vs@keemail.me> | 2020-10-08 13:58:18 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-08 13:58:18 +0300 |
commit | 45b4094c02301ff854b8b8017437ad9989efa117 (patch) | |
tree | 0c7c375a24519fdff596f8377e2a131b98d2501e /src/containers/Page/Page.tsx | |
parent | c3f9271adebf37ed66664d978cfae2a6b327ebff (diff) | |
parent | 80a09a9ec176c7585dca9d81f6b3d690660ce633 (diff) | |
download | which-ui-45b4094c02301ff854b8b8017437ad9989efa117.tar.gz |
Merge pull request #101 from which-ecosystem/feat/modal
ModalScreen component
Diffstat (limited to 'src/containers/Page/Page.tsx')
-rw-r--r-- | src/containers/Page/Page.tsx | 13 |
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 |