File tree Expand file tree Collapse file tree 3 files changed +19
-5
lines changed Expand file tree Collapse file tree 3 files changed +19
-5
lines changed Original file line number Diff line number Diff line change 11import { database } from 'firebase' ;
2+ import * as isObject from 'isobject' ;
23
34export const snapshotToData = (
45 snapshot : database . DataSnapshot ,
56 keyField ?: string
6- ) => ( {
7- ...snapshot . val ( ) ,
8- ...( keyField ? { [ keyField ] : snapshot . key } : null ) ,
9- } ) ;
7+ ) => {
8+ const val = snapshot . val ( ) ;
9+ if ( isObject ( val ) ) {
10+ return {
11+ ...val ,
12+ ...( keyField ? { [ keyField ] : snapshot . key } : null ) ,
13+ } ;
14+ }
15+ return val ;
16+ } ;
Original file line number Diff line number Diff line change 4343 },
4444 "main" : " dist/index.cjs.js" ,
4545 "module" : " dist/index.esm.js" ,
46- "dependencies" : {},
46+ "dependencies" : {
47+ "isobject" : " ^3.0.1"
48+ },
4749 "devDependencies" : {
4850 "@types/react" : " ^16.8.3" ,
4951 "firebase" : " ^5.5.6" ,
Original file line number Diff line number Diff line change @@ -573,6 +573,11 @@ isobject@^2.0.0:
573573 dependencies :
574574 isarray "1.0.0"
575575
576+ isobject@^3.0.1 :
577+ version "3.0.1"
578+ resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df"
579+ integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8=
580+
576581577582 version "2.2.1"
578583 resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz#611ae1acf14f5e81f729507472819fe9733558a9"
You can’t perform that action at this time.
0 commit comments