File tree 2 files changed +26
-1
lines changed
2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -134,3 +134,24 @@ export function extractRefs(
134
134
135
135
return dataAndRefs
136
136
}
137
+
138
+ /**
139
+ * Custom stringifier for [devalue](https://github.com/Rich-Harris/devalue) to support Firestore Timestamp and GeoPoint
140
+ * on SSR.
141
+ */
142
+ export const devalueCustomStringifiers = {
143
+ TimeStamp : ( data : unknown ) => data instanceof Timestamp && data . toJSON ( ) ,
144
+ GeoPoint : ( data : unknown ) => data instanceof GeoPoint && data . toJSON ( ) ,
145
+ }
146
+
147
+ /**
148
+ * Custom parsers for [devalue](https://github.com/Rich-Harris/devalue) to support Firestore Timestamp and GeoPoint on
149
+ * SSR.
150
+ */
151
+ export const devalueCustomParsers = {
152
+ TimeStamp : ( data : ReturnType < Timestamp [ 'toJSON' ] > ) =>
153
+ new Timestamp ( data . seconds , data . nanoseconds ) ,
154
+
155
+ GeoPoint : ( data : ReturnType < GeoPoint [ 'toJSON' ] > ) =>
156
+ new GeoPoint ( data . latitude , data . longitude ) ,
157
+ }
Original file line number Diff line number Diff line change @@ -31,7 +31,11 @@ export type {
31
31
*/
32
32
export { useCollection , useDocument , useFirestore } from './firestore'
33
33
export { firestoreOptionsDefaults as globalFirestoreOptions } from './firestore/bind'
34
- export { firestoreDefaultConverter } from './firestore/utils'
34
+ export {
35
+ firestoreDefaultConverter ,
36
+ devalueCustomParsers ,
37
+ devalueCustomStringifiers ,
38
+ } from './firestore/utils'
35
39
export type {
36
40
UseCollectionOptions ,
37
41
UseDocumentOptions ,
You can’t perform that action at this time.
0 commit comments