File tree 2 files changed +22
-0
lines changed
2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -230,6 +230,22 @@ const DatabaseValue = () => {
230
230
231
231
```
232
232
233
+ #### ` useObjectVal<T>(ref) `
234
+
235
+ As above, but this hook returns the typed contents of ` DataSnapshot.val() ` rather than the
236
+ ` DataSnapshot ` itself.
237
+
238
+ Parameters:
239
+ - ` ref ` : ` firebase.database.Reference `
240
+
241
+ Returns:
242
+ ` ObjectValue ` containing
243
+ - ` error ` : An optional error object returned by Firebase
244
+ - ` loading ` : A ` boolean ` to indicate if the listener is still being loaded
245
+ - ` value ` : A ` firebase.database.DataSnapshot `
246
+
247
+ ```
248
+
233
249
## License
234
250
235
251
* See [LICENSE](/LICENSE)
Original file line number Diff line number Diff line change @@ -11,6 +11,12 @@ export type ObjectHook = {
11
11
loading: boolean;
12
12
value?: DataSnapshot;
13
13
};
14
+ export type ObjectValHook<T> = {
15
+ error?: Object;
16
+ loading: boolean;
17
+ value?: T;
18
+ };
14
19
15
20
declare export function useList(query: Query): ListHook;
16
21
declare export function useObject(query: Query): ObjectHook;
22
+ declare export function useObjectVal<T>(query: Query): ObjectValHook<T>;
You can’t perform that action at this time.
0 commit comments