我使用的是react-router-domv6,我看过其他人的问题,但对我没有帮助;我想要的只是让回到任何一点变得不可能。
const App = () => {
const user = useSelector((state) => state.user.userData);
/* Destructuring the state of auth from the redux store. */
const { isLogged, isVerified, resetPasswordSent, resetPasswordVerified } =
useSelector((state) => state.auth);
const Check = () => {
if (user?.firstTimeAccess === true) {
return <SetProfile />;
} else if (user?.firstTimeAccess === false) {
return <Navigate to="/home" />;
}
};
return (
<Router>
<Routes>
<Route path="/" element={isLogged ? <Check /> : <Landing />} />
<Route
path="/login" …Run Code Online (Sandbox Code Playgroud)