Reach/Router - authenticated vs. protected routes in main component

311 Views Asked by At

I'm trying to get a handle on why a logged-in user at the app root "/" doesn't get redirect to "/user/:uid" when that is specified as the path on the <ProfilePage/> component.

I should note, in my SignIn component I do that in the signIn callback, i.e. navigate(`/user/${uid}`);, but I can't make the path "/" redirect to "/user/:uid" (if logged in). I just get my NotFound.

function Application() {
  const user = useContext(UserContext);
  return user ? (
    <Router>
      <ProfilePage path={`/user/${user.uid}`} authenticatedUser={user} exact />
      <NotFound default />
    </Router>
  ) : (
    <Router>
      <SignIn path="/" />
      <SignUp path="signUp" />
      <PasswordReset path="passwordReset" />
    </Router>
  );
}
0

There are 0 best solutions below