diff --git a/frontend/src/AppRoutes/Private.tsx b/frontend/src/AppRoutes/Private.tsx index 3d4c532e1b..4e5ed9df1e 100644 --- a/frontend/src/AppRoutes/Private.tsx +++ b/frontend/src/AppRoutes/Private.tsx @@ -1,6 +1,6 @@ import { ReactChild, useCallback, useEffect, useMemo, useState } from 'react'; import { useQuery } from 'react-query'; -import { matchPath, useLocation } from 'react-router-dom'; +import { matchPath, Redirect, useLocation } from 'react-router-dom'; import getLocalStorageApi from 'api/browser/localstorage/get'; import setLocalStorageApi from 'api/browser/localstorage/set'; import getAll from 'api/v1/user/get'; @@ -236,13 +236,7 @@ function PrivateRoute({ children }: PrivateRouteProps): JSX.Element { useEffect(() => { // if it is an old route navigate to the new route if (isOldRoute) { - const redirectUrl = oldNewRoutesMapping[pathname]; - - const newLocation = { - ...location, - pathname: redirectUrl, - }; - history.replace(newLocation); + // this will be handled by the redirect component below return; } @@ -296,6 +290,19 @@ function PrivateRoute({ children }: PrivateRouteProps): JSX.Element { } }, [isLoggedInState, pathname, user, isOldRoute, currentRoute, location]); + if (isOldRoute) { + const redirectUrl = oldNewRoutesMapping[pathname]; + return ( + + ); + } + // NOTE: disabling this rule as there is no need to have div return <>{children}; }