These are my public routes
export const PublicRoutes = () => { return ( <Switch> <Route path="/" exact component={Login} /> <Route path={constant.component.logout.url} exact={true} component={Logout} /> <Route path={constant.component.register.url} exact= {true} component={SignUp} /> <Route path={constant.component.forgotPassword.url} exact={true} component={ForgotPassword} /> </Switch> ) } This is my index.js
ReactDOM.render( <React.StrictMode> <AlertProvider template={AlertTemplate} {...options}> <Router> <App /> </Router> </AlertProvider> </React.StrictMode>, document.getElementById('root') ); This is my app.js where I am trying to render routes based on accessToken in the local storage
return ( <> {token ? <DashboardLayout /> : <PublicRoutes />} </> ) And finally this my dashboard layout where I want the authenticated routes to be shown to the right of the sidebar
<> <SideBar> <div className="w-100"> <Switch> <Route path="/dashboard" component={Dashboard} /> <Route path="/my-account" component={Account} /> </Switch> </div> <Footer> </> Now, when I login, it redirects me to "/dashboard" the url changes but the page shows an empty screen and it works if I refresh the page manually. What am I doing wrong? Thanks