File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -24,15 +24,15 @@ export function useUser<T = unknown>(options?: ReactFireOptions<T>): ObservableS
24
24
25
25
const observableId = `auth:user:${ auth . name } ` ;
26
26
const observable$ = user ( auth ) ;
27
+ const _options : ReactFireOptions < T > = { ...options } ?? { } ;
27
28
28
- let currentUser = auth . currentUser ;
29
-
30
- // Only use options.initialData if auth.currentUser is unavailable
31
- if ( ! currentUser && ( options ?. initialData ?? options ?. startWithValue ) ) {
32
- currentUser = options . initialData ?? options . startWithValue ;
29
+ // only set/override initialData if auth has finished loading
30
+ if ( auth . currentUser !== undefined ) {
31
+ _options . initialData = auth . currentUser ;
32
+ _options . startWithValue = auth . currentUser ;
33
33
}
34
34
35
- return useObservable ( observableId , observable$ , { ... options , initialData : currentUser } ) ;
35
+ return useObservable ( observableId , observable$ , _options ) ;
36
36
}
37
37
38
38
export function useIdTokenResult ( user : User , forceRefresh : boolean = false , options ?: ReactFireOptions < IdTokenResult > ) : ObservableStatus < IdTokenResult > {
You can’t perform that action at this time.
0 commit comments