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 1
1
import { database } from 'firebase' ;
2
+ import * as isObject from 'isobject' ;
2
3
3
4
export const snapshotToData = (
4
5
snapshot : database . DataSnapshot ,
5
6
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 43
43
},
44
44
"main" : " dist/index.cjs.js" ,
45
45
"module" : " dist/index.esm.js" ,
46
- "dependencies" : {},
46
+ "dependencies" : {
47
+ "isobject" : " ^3.0.1"
48
+ },
47
49
"devDependencies" : {
48
50
"@types/react" : " ^16.8.3" ,
49
51
"firebase" : " ^5.5.6" ,
Original file line number Diff line number Diff line change @@ -573,6 +573,11 @@ isobject@^2.0.0:
573
573
dependencies :
574
574
isarray "1.0.0"
575
575
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
+
576
581
577
582
version "2.2.1"
578
583
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