1
Sun Oct 16 2022 11:37:23 GMT+0000 (Coordinated Universal Time)
Saved by
@Vrushabh_123
// RequiresAuth.js
export function RequiresAuth({ children, login }) {
return login ? children : <Navigate to="/login" replace />;
}
// App.js
<Route
path="/address"
element={
<RequiresAuth login={login}>
<Address />
</RequiresAuth>
}
/>
// Routing
if you are not logged in
/address
/login /address
when you are going back
/login should not come again
content_copyCOPY
Comments