Skip to content

Commit

Permalink
fix(patches): fixed possible nullpointer
Browse files Browse the repository at this point in the history
  • Loading branch information
BowlingX committed Dec 19, 2019
1 parent 11c947d commit 12b339f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,9 @@ export const createQueriesFromPatch = <T = object>(
return next
}
const possibleParameter = get(config, objectPath)
if (
possibleParameter !== undefined &&
typeof possibleParameter !== 'function'
) {
const isNotCallable = typeof possibleParameter !== 'function'

if (possibleParameter !== undefined && isNotCallable) {
// If we have an object as result, we create patches for each parameter inside the subtree
const patches = findDeepPatches(
possibleParameter,
Expand All @@ -104,6 +103,11 @@ export const createQueriesFromPatch = <T = object>(
...createQueriesFromPatch<T>(config, ns, patches, state, initialState)
}
}

if (isNotCallable) {
return next
}

const { name, serializer, skip } = possibleParameter()
// @ts-ignore
const value = get(state, objectPath)
Expand Down

0 comments on commit 12b339f

Please sign in to comment.