Skip to content

Commit

Permalink
fix(auth): skip initial load if currentUser is set
Browse files Browse the repository at this point in the history
  • Loading branch information
andipaetzold committed Oct 17, 2021
1 parent 7d5b185 commit b345137
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/auth/useAuthState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ export function useAuthState(auth: Auth): UseAuthStateResult {
[]
);

return useListen(auth, onChange, () => true);
return useListen(auth, onChange, () => true, auth.currentUser);
}
5 changes: 3 additions & 2 deletions src/internal/useListen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ export type UseListenOnChange<Value, Error, Reference> = (
export function useListen<Value, Error, Reference>(
reference: Reference | undefined,
onChange: UseListenOnChange<Value, Error, Reference>,
isEqual: (a: Reference | undefined, b: Reference | undefined) => boolean
isEqual: (a: Reference | undefined, b: Reference | undefined) => boolean,
defaultValue?: Value
): ValueHookResult<Value, Error> {
const { error, loading, setLoading, setError, setValue, value } = useLoadingValue<Value, Error>();
const { error, loading, setLoading, setError, setValue, value } = useLoadingValue<Value, Error>(defaultValue);

const stableRef = useStableValue(reference ?? undefined, isEqual);

Expand Down

0 comments on commit b345137

Please sign in to comment.