File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -80,7 +80,12 @@ export function _useFirestoreRef(
8080
8181 const data = options . target || ref < unknown | null > ( )
8282 // 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+ )
8489 // TODO: allow passing pending and error refs as option for when this is called using the options api
8590 const pending = ref ( true )
8691 const error = ref < FirestoreError > ( )
Original file line number Diff line number Diff line change @@ -54,7 +54,8 @@ type FirestoreDataSource =
5454export function getInitialValue (
5555 type : 'f' | 'r' ,
5656 ssrKey ?: string | undefined ,
57- dataSource ?: _Nullable < FirestoreDataSource >
57+ dataSource ?: _Nullable < FirestoreDataSource > ,
58+ fallbackValue ?: unknown
5859) {
5960 const initialState : Record < string , unknown > = useSSRInitialState ( ) [ type ] || { }
6061 const key = ssrKey || getFirestoreSourceKey ( dataSource )
@@ -63,7 +64,7 @@ export function getInitialValue(
6364
6465 // returns undefined if no key, otherwise initial state or undefined
6566 // undefined should be treated as no initial state
66- return key && initialState [ key ]
67+ return key && key in initialState ? initialState [ key ] : fallbackValue
6768}
6869
6970export function setInitialValue (
You can’t perform that action at this time.
0 commit comments