Skip to content

Commit

Permalink
use getState and updateState setters in reduxLeaves
Browse files Browse the repository at this point in the history
  • Loading branch information
richardcrng committed Jun 4, 2019
1 parent 8dfcfc6 commit b7624d0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/reduxLeaves.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as R from 'ramda'
import { actionsFor } from './actions/';
import { leafReducer } from './leafReducer';
import { standardiseReducersDict } from './reducersDict/standardise/standardiseReducersDict';
import { getState, updateState } from './utils';

export const reduxLeaves = (initialState, reducersDict = {}) => {
const leafReducersDict = standardiseReducersDict(reducersDict)
Expand All @@ -10,7 +11,7 @@ export const reduxLeaves = (initialState, reducersDict = {}) => {
const { leaf = {} } = action;
const { path = [], condition, creatorKey, custom } = leaf

const prevLeafState = R.path(path, state)
const prevLeafState = getState(state, path)

const newLeafState = leafReducer(
prevLeafState,
Expand All @@ -20,7 +21,7 @@ export const reduxLeaves = (initialState, reducersDict = {}) => {
leafReducersDict
)

return R.assocPath(path, newLeafState, state)
return updateState(state, path, newLeafState)
}

const actions = actionsFor(R.clone(initialState), leafReducersDict)
Expand Down

0 comments on commit b7624d0

Please sign in to comment.