Skip to content

Commit

Permalink
fix: mutate user if token changed
Browse files Browse the repository at this point in the history
  • Loading branch information
DanyaIzm committed Dec 20, 2024
1 parent e95fa74 commit e67afd1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/hooks/use-user.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import useSWRImmutable from "swr/immutable";
const useUser = () => {
const { token } = useContext(AuthContext);

useEffect(() => {
mutate();
}, [token]);

const { data, error, isLoading, mutate } = useSWR(
token ? "/auth/users/me" : null,
getAuthFetcher(token),
Expand Down

0 comments on commit e67afd1

Please sign in to comment.