Skip to content

Commit 638aba6

Browse files
authored
rxfire: objectVal bugfix (#2352)
1 parent ba1932f commit 638aba6

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/rxfire/database/object/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,15 @@ export function objectVal<T>(
4444
}
4545

4646
export function changeToData(change: QueryChange, keyField?: string): {} {
47+
const val = change.snapshot.val();
48+
49+
// val can be a primitive type
50+
if (typeof val !== 'object') {
51+
return val;
52+
}
53+
4754
return {
48-
...change.snapshot.val(),
55+
...val,
4956
...(keyField ? { [keyField]: change.snapshot.key } : null)
5057
};
5158
}

0 commit comments

Comments
 (0)