From b04936697f8a90d686efe7429cc6494019053031 Mon Sep 17 00:00:00 2001 From: Kai Moseley Date: Thu, 1 Dec 2016 23:18:18 +0000 Subject: [PATCH] Clean up buildReducers --- src/index.js | 2 ++ src/redux-arg/buildReducers.js | 25 +++++++++---------------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/index.js b/src/index.js index b58e876..90d2589 100644 --- a/src/index.js +++ b/src/index.js @@ -38,3 +38,5 @@ store.dispatch(test.actionsObject.example.form2.reset()); store.dispatch(test.actionsObject.example.form2.replace({ toast: 'nommyNom' })); store.dispatch(test.actionsObject.example.form2.reset()); +console.log(111, test.selectorsObject.example.form2(store.getState())); + diff --git a/src/redux-arg/buildReducers.js b/src/redux-arg/buildReducers.js index 3a082f9..60330e0 100644 --- a/src/redux-arg/buildReducers.js +++ b/src/redux-arg/buildReducers.js @@ -44,16 +44,14 @@ export function buildReducers(name: string, structure: ShapeStructure, { //child reducers, we will either recursively call buildReducers, or we will call the //createReducer function, which will create the correct reducer for the given structure //(which can be either object, array, or primitive). - let childReducer = containsReducers ? buildReducers(propName, propStructure, { - locationString: locationString ? `${locationString}.${propName}` : propName, - baseSelector: state => { - const stuff = baseSelector(state); - console.log(224, 'Am I getting the way?', stuff, propName); - return stuff[propName]; - } - }) : createReducer(propValue, { - locationString, - }); + let childReducer = containsReducers + ? buildReducers(propName, propStructure, { + locationString: locationString ? `${locationString}.${propName}` : propName, + baseSelector: state => baseSelector(state)[propName], + }) + : createReducer(propValue, { + locationString, + }); //As the object is built up, we want to assign the reducers/actions created //by the child to a location on the reducers/actions object which will match up @@ -70,12 +68,7 @@ export function buildReducers(name: string, structure: ShapeStructure, { }, selectorsObject: { ...memo.selectorsObject, - [propName]: containsReducers ? childReducer.selectorsObject : state => { - console.log(222, 'About to call!', propName) - const parentStuff = baseSelector(state); - console.log(223, parentStuff); - return parentStuff[propName]; - } + [propName]: containsReducers ? childReducer.selectorsObject : state => baseSelector(state)[propName], }, }; }