const { userInfo } = useSelector((state) => state.userLogin);
const navigate = useNavigate();
useEffect(() => {
if (!userInfo.mobile) {
navigate("/sign/");
}
}, [navigate]);
here I just want to redirect the user if he is not logged in
const { userInfo } = useSelector((state) => state.userLogin);
const navigate = useNavigate();
useEffect(() => {
if (!userInfo.mobile) {
navigate("/sign/");
}
}, [navigate]);
here I just want to redirect the user if he is not logged in
that's because since the component you're using useNavigate is not a child of . you can't use it outside router