You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: firestore/README.md
+42-2Lines changed: 42 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -136,6 +136,8 @@ Returns:
136
136
-`error`: Any `firestore.FirestoreError` returned by Firebase when trying to load the data, or `undefined` if there is no error
137
137
-`snapshot`: a `firestore.QuerySnapshot`, or `undefined` if no query is supplied. This allows access to the underlying snapshot if needed for any reason, e.g. to view the snapshot metadata
138
138
139
+
See [Transforming data](#transforming-data) for how to transform data as it leaves Firestore and access the underlying `id` and `ref` fields of the snapshot.
140
+
139
141
### useCollectionDataOnce
140
142
141
143
```js
@@ -160,6 +162,8 @@ Returns:
160
162
-`error`: Any `firestore.FirestoreError` returned by Firebase when trying to load the data, or `undefined` if there is no error
161
163
-`snapshot`: a `firestore.QuerySnapshot`, or `undefined` if no query is supplied. This allows access to the underlying snapshot if needed for any reason, e.g. to view the snapshot metadata
162
164
165
+
See [Transforming data](#transforming-data) for how to transform data as it leaves Firestore and access the underlying `id` and `ref` fields of the snapshot.
166
+
163
167
### useDocument
164
168
165
169
```js
@@ -251,6 +255,8 @@ Returns:
251
255
-`error`: Any `firestore.FirestoreError` returned by Firebase when trying to load the data, or `undefined` if there is no error
252
256
-`snapshot`: a `firestore.DocumentSnapshot`, or `undefined` if no query is supplied. This allows access to the underlying snapshot if needed for any reason, e.g. to view the snapshot metadata
253
257
258
+
See [Transforming data](#transforming-data) for how to transform data as it leaves Firestore and access the underlying `id` and `ref` fields of the snapshot.
259
+
254
260
### useDocumentDataOnce
255
261
256
262
```js
@@ -276,8 +282,42 @@ Returns:
276
282
-`snapshot`: a `firestore.DocumentSnapshot`, or `undefined` if no query is supplied. This allows access to the underlying snapshot if needed for any reason, e.g. to view the snapshot metadata
277
283
-`reload()`: a function that can be called to trigger a reload of the data
278
284
285
+
See [Transforming data](#transforming-data) for how to transform data as it leaves Firestore and access the underlying `id` and `ref` fields of the snapshot.
286
+
279
287
## Transforming data
280
288
281
-
Firestore allows a restricted number of data types in its store, which may not be flexible enough for your application. As of Firebase 9, there is a built in FirestoreDataConverter which allows you to transform data as it leaves the Firestore database. This is described here: https://firebase.google.com/docs/reference/js/firestore_.firestoredataconverter
289
+
Firestore allows a restricted number of data types in its store, which may not be flexible enough for your application. As of Firebase 9, there is a built in FirestoreDataConverter which allows you to transform data as it leaves the Firestore database, as well as access the `id` and `ref` fields of the underlying snapshot. This is described here: https://firebase.google.com/docs/reference/js/firestore_.firestoredataconverter
290
+
291
+
> NOTE: This replaces the `transform`, `idField` and `refField` options that were available in `react-firebase-hooks` v4 and earlier.
292
+
293
+
### Example
282
294
283
-
> This has replaced the `transform`, `idField` and `refField` options that were available in `react-firebase-hooks` v4 and earlier.
0 commit comments