I'm using login with firebase which has hooks like this
const [user, loading, error] = useAuthState(auth);
When the user variable changes, it's suppose to indicate they have logged in.
So I do this
useEffect(() => {
if (loading) return;
if (!user) return navigate("/");
//otherwise do some network stuff
}, [user, loading]);
But the problem now is that I'm hitting the server twice because useEffect is always called twice in strict mode.
And I'm not suppose to turn off strict mode because it's good for you.
So what is the solution?