Skip to content

Commit

Permalink
fix: return before hook
Browse files Browse the repository at this point in the history
  • Loading branch information
wildcatco committed Aug 9, 2023
1 parent 8c5cbaa commit b199c58
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/apis/hooks/users/useUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,13 @@ export default function useUser(
enabled: !!userId,
});

if (userTypeError) {
return {
user: null,
isLoading: false,
error: userTypeError,
status: 'unauthenticated',
};
}
useEffect(() => {
if (isSuccess) {
queryClient.refetchQueries({
queryKey: ['user', data.userId],
});
}
}, [isSuccess]);

const user: User | null =
data && userData
Expand Down Expand Up @@ -78,13 +77,14 @@ export default function useUser(
}
: null;

useEffect(() => {
if (isSuccess) {
queryClient.refetchQueries({
queryKey: ['user', data.userId],
});
}
}, [isSuccess]);
if (userTypeError) {
return {
user: null,
isLoading: false,
error: userTypeError,
status: 'unauthenticated',
};
}

return {
user,
Expand Down

0 comments on commit b199c58

Please sign in to comment.