When i use useSelector or useNavigate, my screen went blank without any error

Viewed 263
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

1 Answers

that's because since the component you're using useNavigate is not a child of . you can't use it outside router

Related