I have a function that redirects my user once they enter the page so they don't receive a not found, it is executed on an useEffect. My problem is that after the first load of the page I don't want the user to be redirected anymore and they should refresh and stay in the same page, how can I tell the difference if the user is entering the page or refreshing it?
const onAppLoad = useCallback(async () => {
Auth.currentSession()
.then(response => {
authRef.current = response;
setUser(response.idToken.payload);
navigate('/employees');
setIsAuthenticated(true);
})
.catch(() => {
navigate('/login');
})
.finally(() => {
setFetching(false);
});
}, []);