I am making an e-store. I have the uid of logged-in user. I am trying to make a condition that if the logged in user uid is not equal to admin uid, then I do not want that user to go on the admin page. The useEffect runs infinite.
const navigate = useNavigate();
const user = localStorage.getItem("uid");
useEffect(() => {
if (user === 'at64ZIYgqaawRyCAkH6xMYBRNwS2') {
navigate('/admin')
}
else {
navigate('/home')
}
})