React Router - How to redirect user if logged in?
问题 I'm using react-router-dom to manage my routes: const Routes = () => { return ( <BrowserRouter> <div> <Route path="/" component={Navbar} /> <Switch> <Route exact path="/" component={Main} /> <Route path="/signin" component={SignIn} /> <Route path="/signup" component={SignUp} /> <PrivateRoute path="/dashboard" component={DashboardRoutes} /> <Route path="*" component={() => <h1>Page not found</h1>} /> </Switch> </div> <div> <Route path="/" component={Footer} /> </div> </BrowserRouter> ); }; I