How can I set browser url manually in react js
I'm using outlet component to render child components, I have also set up ProtectedRout component which wraps <Outlet> component, ProtectedRout returns children component if isAuthenticated is true and returns <Login/> components if it is false, It works without any problem, Since I'm directly returning login component instead of using <Navigate to ="/login/> the url in the browser address bar doesn't change, but I want it to be mydomain/login, How can I achieve this?
const ProtectedRout = ({children})=>{
const {isAuthenticated}= useAuth()
return (isAuthenticated ? children : <Login/>)
}
0 Replies