mirror of
https://github.com/zhigang1992/react-native-firebase.git
synced 2026-04-24 04:24:52 +08:00
[database][js] fixed a regression where snapshot.child() would no longer work on array values
This commit is contained in:
@@ -51,6 +51,7 @@ export default class DataSnapshot {
|
||||
* @returns {Snapshot}
|
||||
*/
|
||||
child(path: string): DataSnapshot {
|
||||
// TODO validate path is a string
|
||||
let value = deepGet(this._value, path);
|
||||
if (value === undefined) value = null;
|
||||
const childRef = this.ref.child(path);
|
||||
@@ -59,9 +60,9 @@ export default class DataSnapshot {
|
||||
key: childRef.key,
|
||||
exists: value !== null,
|
||||
|
||||
// todo this is wrong - child keys needs to be the ordered keys, from FB
|
||||
// todo potential solution is build up a tree/map of a snapshot and its children
|
||||
// todo natively and send that back to JS to be use in this class.
|
||||
// TODO this is wrong - child keys needs to be the ordered keys, from FB
|
||||
// TODO potential solution is build up a tree/map of a snapshot and its children
|
||||
// TODO natively and send that back to JS to be use in this class.
|
||||
|
||||
// null check to keep flow happy even though isObject already does this
|
||||
childKeys: isObject(value) && value !== null ? Object.keys(value) : [],
|
||||
|
||||
Reference in New Issue
Block a user