add back withRouter to see if it fixes the app not working
This commit is contained in:
parent
228dc1c96a
commit
c3d207e547
1 changed files with 10 additions and 5 deletions
|
@ -1,7 +1,7 @@
|
||||||
// @flow
|
// @flow
|
||||||
import * as PAGES from 'constants/pages';
|
import * as PAGES from 'constants/pages';
|
||||||
import React, { useEffect } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { Route, Redirect, Switch } from 'react-router-dom';
|
import { Route, Redirect, Switch, withRouter } from 'react-router-dom';
|
||||||
import SettingsPage from 'page/settings';
|
import SettingsPage from 'page/settings';
|
||||||
import HelpPage from 'page/help';
|
import HelpPage from 'page/help';
|
||||||
import ReportPage from 'page/report';
|
import ReportPage from 'page/report';
|
||||||
|
@ -38,6 +38,7 @@ if ('scrollRestoration' in history) {
|
||||||
type PrivateRouteProps = {
|
type PrivateRouteProps = {
|
||||||
component: any,
|
component: any,
|
||||||
isAuthenticated: boolean,
|
isAuthenticated: boolean,
|
||||||
|
location: { pathname: string },
|
||||||
};
|
};
|
||||||
|
|
||||||
function PrivateRoute(props: PrivateRouteProps) {
|
function PrivateRoute(props: PrivateRouteProps) {
|
||||||
|
@ -49,7 +50,7 @@ function PrivateRoute(props: PrivateRouteProps) {
|
||||||
isAuthenticated || !IS_WEB ? (
|
isAuthenticated || !IS_WEB ? (
|
||||||
<Component {...props} />
|
<Component {...props} />
|
||||||
) : (
|
) : (
|
||||||
<Redirect to={`/$/${PAGES.AUTH}?redirect=${window.location.pathname}`} />
|
<Redirect to={`/$/${PAGES.AUTH}?redirect=${props.location.pathname}`} />
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
@ -59,11 +60,15 @@ function PrivateRoute(props: PrivateRouteProps) {
|
||||||
type Props = {
|
type Props = {
|
||||||
currentScroll: number,
|
currentScroll: number,
|
||||||
isAuthenticated: boolean,
|
isAuthenticated: boolean,
|
||||||
|
location: { pathname: string, search: string },
|
||||||
};
|
};
|
||||||
|
|
||||||
function AppRouter(props: Props) {
|
function AppRouter(props: Props) {
|
||||||
const { currentScroll, isAuthenticated } = props;
|
const {
|
||||||
const { pathname } = window.location;
|
currentScroll,
|
||||||
|
location: { pathname },
|
||||||
|
isAuthenticated,
|
||||||
|
} = props;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
window.scrollTo(0, currentScroll);
|
window.scrollTo(0, currentScroll);
|
||||||
|
@ -120,4 +125,4 @@ function AppRouter(props: Props) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default AppRouter;
|
export default withRouter(AppRouter);
|
||||||
|
|
Loading…
Add table
Reference in a new issue