I might of missed something, but is there anything wrong with doing something like this?
<Route path="/" element={user ? <Home /> : <Navigate to="/login" />} />
π€ looking at this it should work, I don't know if react-router can detect the full tree of routes using this way π€
react-router
I think you should navigate to "/dashboard" (or wherever you want him to go after logging in) instead of "/login".
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I might of missed something, but is there anything wrong with doing something like this?
π€ looking at this it should work, I don't know if
react-router
can detect the full tree of routes using this way π€I think you should navigate to "/dashboard" (or wherever you want him to go after logging in) instead of "/login".