File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -230,6 +230,22 @@ const DatabaseValue = () => {
230230
231231```
232232
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+
233249## License
234250
235251* See [LICENSE](/LICENSE)
Original file line number Diff line number Diff line change @@ -11,6 +11,12 @@ export type ObjectHook = {
1111 loading: boolean;
1212 value?: DataSnapshot;
1313};
14+ export type ObjectValHook<T> = {
15+ error?: Object;
16+ loading: boolean;
17+ value?: T;
18+ };
1419
1520declare export function useList(query: Query): ListHook;
1621declare 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