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
2424
2525 const observableId = `auth:user:${ auth . name } ` ;
2626 const observable$ = user ( auth ) ;
27+ const _options : ReactFireOptions < T > = { ...options } ?? { } ;
2728
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 ;
3333 }
3434
35- return useObservable ( observableId , observable$ , { ... options , initialData : currentUser } ) ;
35+ return useObservable ( observableId , observable$ , _options ) ;
3636}
3737
3838export function useIdTokenResult ( user : User , forceRefresh : boolean = false , options ?: ReactFireOptions < IdTokenResult > ) : ObservableStatus < IdTokenResult > {
You can’t perform that action at this time.
0 commit comments