Skip to content

Commit 0d3434f

Browse files
committed
Tweak transform documentation
1 parent c03d136 commit 0d3434f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

database/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,7 @@ Returns:
175175

176176
## Transforming data
177177

178-
Firebase allows a restricted number of data types in its store. The application, on the other hand, might require converting some of these types into whatever it really needs, `Date` types being a common case.
179-
180-
Both `useListVals` and `useObjectVal` support an optional `transform` function which allows the transformation of the underlying Firebase data into whatever format the application requires.
178+
Firebase allows a restricted number of data types in the Realtime Database, which may not be flexible enough for your application. Both `useListVals` and `useObjectVal` support an optional `transform` function which allows the transformation of the underlying Firebase data into whatever format the application require, e.g. a `Date` type.
181179

182180
```js
183181
transform?: (val: any) => T;
@@ -187,6 +185,8 @@ The `transform` function is passed a single row of a data, so will be called onc
187185

188186
The `transform` function will not receive the `key` or `ref` values referenced in the properties named in the `keyField` or `refField` options, nor it is expected to produce them. Either or both, if specified, will be merged afterwards.
189187

188+
If the `transform` function is defined within your React component, it is recomended that you memoize the function to prevent unnecessry renders.
189+
190190
#### Full Example
191191

192192
```js

firestore/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,7 @@ Returns:
272272

273273
## Transforming data
274274

275-
Firestore allows a restricted number of data types in its store. The application, on the other hand, might require converting some of these types into whatever it really needs, `Date` types being a common case.
276-
277-
Both `useCollectionData` and `useDocumentData` support an optional `transform` function which allows the transformation of the underlying Firestore data into whatever format the application requires.
275+
Firestore allows a restricted number of data types in its store, which may not be flexible enough for your application. Both `useCollectionData` and `useDocumentData` support an optional `transform` function which allows the transformation of the underlying Firestore data into whatever format the application requires, e.g. a `Date` type.
278276

279277
```js
280278
transform?: (val: any) => T;
@@ -283,3 +281,5 @@ transform?: (val: any) => T;
283281
The `transform` function is passed a single row of a data, so will be called once when used with `useDocumentData` and multiple times when used with `useCollectionData`.
284282

285283
The `transform` function will not receive the `id` or `ref` values referenced in the properties named in the `idField` or `refField` options, nor it is expected to produce them. Either or both, if specified, will be merged afterwards.
284+
285+
If the `transform` function is defined within your React component, it is recomended that you memoize the function to prevent unnecessry renders.

0 commit comments

Comments
 (0)