diff options
author | eug-vs <eug-vs@keemail.me> | 2020-10-07 23:25:52 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2020-10-07 23:25:52 +0300 |
commit | 4471fef74dfe312a8cf6a1440f5a703e897af136 (patch) | |
tree | afbd8d0f565f7c270c7c63e4765d8810c30af890 /src/containers/Page/Page.tsx | |
parent | c3f9271adebf37ed66664d978cfae2a6b327ebff (diff) | |
download | which-ui-4471fef74dfe312a8cf6a1440f5a703e897af136.tar.gz |
feat: wire modal routes
Diffstat (limited to 'src/containers/Page/Page.tsx')
-rw-r--r-- | src/containers/Page/Page.tsx | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/containers/Page/Page.tsx b/src/containers/Page/Page.tsx index 7df62cd..51b6d21 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,13 @@ const Page: React.FC = () => { const history = useHistory(); const isMobile = useMediaQuery(theme.breakpoints.down('sm')); - useEffect(() => { - return history.listen(() => { + useEffect(() => history.listen((update: HistoryChange) => { + console.log(update) + if (!update.state?.background) { + console.log('scrolling') window.scrollTo(0, 0); - }); - }, [history]); + } + }), [history]); return ( <SnackbarProvider |