File tree 2 files changed +9
-3
lines changed
2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -80,7 +80,12 @@ export function _useFirestoreRef(
80
80
81
81
const data = options . target || ref < unknown | null > ( )
82
82
// set the initial value from SSR even if the ref comes from outside
83
- data . value = getInitialValue ( 'f' , options . ssrKey , initialSourceValue )
83
+ data . value = getInitialValue (
84
+ 'f' ,
85
+ options . ssrKey ,
86
+ initialSourceValue ,
87
+ data . value
88
+ )
84
89
// TODO: allow passing pending and error refs as option for when this is called using the options api
85
90
const pending = ref ( true )
86
91
const error = ref < FirestoreError > ( )
Original file line number Diff line number Diff line change @@ -54,7 +54,8 @@ type FirestoreDataSource =
54
54
export function getInitialValue (
55
55
type : 'f' | 'r' ,
56
56
ssrKey ?: string | undefined ,
57
- dataSource ?: _Nullable < FirestoreDataSource >
57
+ dataSource ?: _Nullable < FirestoreDataSource > ,
58
+ fallbackValue ?: unknown
58
59
) {
59
60
const initialState : Record < string , unknown > = useSSRInitialState ( ) [ type ] || { }
60
61
const key = ssrKey || getFirestoreSourceKey ( dataSource )
@@ -63,7 +64,7 @@ export function getInitialValue(
63
64
64
65
// returns undefined if no key, otherwise initial state or undefined
65
66
// undefined should be treated as no initial state
66
- return key && initialState [ key ]
67
+ return key && key in initialState ? initialState [ key ] : fallbackValue
67
68
}
68
69
69
70
export function setInitialValue (
You can’t perform that action at this time.
0 commit comments