diff --git a/src/app.tsx b/src/app.tsx index 93d06482f..95cf9fbbf 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -4,6 +4,7 @@ import { HashRouter as Router, Route, Switch, + useLocation, } from 'react-router-dom'; import { AppContext, AppProvider } from './context/App'; @@ -15,24 +16,16 @@ import { NotificationsRoute } from './routes/Notifications'; import { SettingsRoute } from './routes/Settings'; import { Sidebar } from './components/Sidebar'; -export const PrivateRoute = ({ component: Component, ...rest }) => { +function RequireAuth({ children }) { const { isLoggedIn } = useContext(AppContext); + const location = useLocation(); - return ( - - isLoggedIn ? ( - - ) : ( - - ) - } - /> + return isLoggedIn ? ( + children + ) : ( + ); -}; +} export const App = () => { return ( @@ -43,11 +36,28 @@ export const App = () => { - - - - - + + + + + + + + + + + + + + + + + + + + + +