Improved it a tad bit more

This commit is contained in:
Tiago Ribeiro
2023-04-12 17:28:52 +01:00
parent a0cce321d1
commit 399e222791
3 changed files with 7 additions and 12 deletions

View File

@@ -10,6 +10,7 @@ export default function useUser({redirectTo = "", redirectIfFound = false} = {})
const {data: user, mutate: mutateUser, isLoading} = useSWR<User>("/api/user", fetcher);
useEffect(() => {
console.log("HERE!!!");
// if no redirect needed, just return (example: already on /dashboard)
// if user data not yet there (fetch in progress, logged in or not) then don't do anything yet
if (!redirectTo || !user) return;