skip to Main Content

Mongodb – If Token is not Present I want to redirect the page to login but its not working. When no token is present or logout i want to redirect the page login

I am Using React Router Dom V6 Here if(!localStorage.getItem("token")){ navigate("/login") } is not Working import React,{useState,useEffect} from 'react'; import axios from 'axios'; import { useNavigate } from 'react-router-dom'; const Home = (props) => { const [user,setUser]=useState(null); let navigate = useNavigate();…

VIEW QUESTION
Back To Top
Search