score:1

Accepted answer

you are using react-router-dom@6. routing/navigation in rrdv6 can use either absolute or relative paths. the difference is a leading "/" for the path. navigate("./homepage") is a relative path from the current location.

the following are the same:

  • navigate("./homepage")
  • navigate("homepage")

the result is that the user is navigated to a "homepage" relative to the current path.

since "/homepage" is a root route you should use an absolute path.

navigate("/homepage")

navigate("../homepage") could also work since you are in the "/login" route.

score:1

you should pass "/homepage" to navigate without the .


Related Query

More Query from same tag