Skip to content

Commit eb949ba

Browse files
committed
Version v1.2.4 (#60)
* `populatedDataToJS`: Checks for existence of child objects before checking child parameter (fixes `param` of `undefined` errors )
1 parent 71a3d7d commit eb949ba

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-redux-firebase",
3-
"version": "1.2.3",
3+
"version": "1.2.4",
44
"description": "Redux integration for Firebase. Comes with a Higher Order Component for use with React.",
55
"main": "dist/index.js",
66
"module": "src/index.js",

src/helpers.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,15 +246,18 @@ export const populatedDataToJS = (data, path, populates, notSetValue) => {
246246
const pathString = p.childParam
247247
? `${p.root}/${dataToJS(data, path)[p.child]}/${p.childParam}`
248248
: `${p.root}/${dataToJS(data, path)[p.child]}`
249+
249250
if (dataToJS(data, pathString)) {
250251
return {
251252
...dataToJS(data, path),
252253
[p.child]: dataToJS(data, pathString)
253254
}
254255
}
256+
255257
// matching child does not exist
256258
return dataToJS(data, path)
257259
}
260+
258261
return {
259262
...dataToJS(data, path),
260263
[p.child]: buildChildList(data, dataToJS(data, path)[p.child], p)
@@ -263,7 +266,7 @@ export const populatedDataToJS = (data, path, populates, notSetValue) => {
263266
// list with child param in each item
264267
return mapValues(dataToJS(data, path), (child, i) => {
265268
// no matching child parameter
266-
if (!child[p.child]) {
269+
if (!child || !child[p.child]) {
267270
return child
268271
}
269272
// populate child is key

0 commit comments

Comments
 (0)