@@ -41,8 +41,8 @@ const initialStatesMap = new WeakMap<FirebaseApp, SSRStore>()
41
41
* @returns the initial states for the current firebaseApp
42
42
*/
43
43
export function useSSRInitialState (
44
- initialState ? : SSRStore ,
45
- firebaseApp : FirebaseApp = useFirebaseApp ( )
44
+ initialState : SSRStore | undefined ,
45
+ firebaseApp : FirebaseApp
46
46
) : SSRStore {
47
47
// get initial state based on the current firebase app
48
48
if ( ! initialStatesMap . has ( firebaseApp ) ) {
@@ -60,15 +60,16 @@ export function getInitialValue(
60
60
_FirestoreDataSource | DatabaseReference | DatabaseQuery | StorageReference
61
61
> ,
62
62
ssrKey : string | undefined ,
63
- fallbackValue : unknown
63
+ fallbackValue : unknown ,
64
+ firebaseApp : FirebaseApp
64
65
) {
65
66
if ( ! dataSource ) return fallbackValue
66
67
67
68
const [ sourceType , path ] = getDataSourceInfo ( dataSource )
68
69
if ( ! sourceType ) return fallbackValue
69
70
70
71
const initialState : Record < string , unknown > =
71
- useSSRInitialState ( ) [ sourceType ] || { }
72
+ useSSRInitialState ( undefined , firebaseApp ) [ sourceType ] || { }
72
73
const key = ssrKey || path
73
74
74
75
// TODO: warn for queries on the client if there are other keys and this is during hydration
@@ -82,14 +83,18 @@ export function deferInitialValueSetup(
82
83
_FirestoreDataSource | DatabaseReference | DatabaseQuery | StorageReference
83
84
> ,
84
85
ssrKey : string | undefined | null ,
85
- promise : Promise < unknown >
86
+ promise : Promise < unknown > ,
87
+ firebaseApp : FirebaseApp
86
88
) {
87
89
if ( ! dataSource ) return
88
90
89
91
const [ sourceType , path ] = getDataSourceInfo ( dataSource )
90
92
if ( ! sourceType ) return
91
93
92
- const initialState : Record < string , unknown > = useSSRInitialState ( ) [ sourceType ]
94
+ const initialState : Record < string , unknown > = useSSRInitialState (
95
+ undefined ,
96
+ firebaseApp
97
+ ) [ sourceType ]
93
98
const key = ssrKey || path
94
99
95
100
if ( key ) {
0 commit comments