Created
November 2, 2015 00:09
-
-
Save chranderson/af26b10b69e41687594a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/container/form1.js | |
// when i add a file to this input, it triggers the FORM2 reducer's case: redux-form/CHANGE' and calls function in FORM2. | |
<input type="file" {...fileField}/> | |
// src/redux/modules/form1.js | |
export default function reducer(state = initialState, action = {}) { | |
switch (action.type) { | |
case FILE_SELECTED: | |
return {....} | |
} | |
}): | |
// src/container/form2.js | |
<select value="x" {...dataType}/> | |
// src/redux/modules/form2.js | |
// call updateFieldMap() on action 'redux-form/CHANGE' | |
updateFieldMap(state, action) { | |
...do something | |
}; | |
export default function reducer(state = initialState, action = {}) { | |
switch (action.type) { | |
[...] | |
case DATA_SUCCESS: | |
return { | |
...state, | |
loadingData: false, | |
loadedData: true, | |
fieldMapMade: true, | |
next: createFieldMap(action.result, state.fieldMap, state.fieldMapMade), | |
response: action.res, | |
gotData: true, | |
error: null, | |
}; | |
// im trying to get this to call only when the 'redux-form/CHANGE' action comes from FORM2. | |
case 'redux-form/CHANGE': | |
return updateFieldMap(state, action); | |
case PATCH_FIELDMAP: | |
return { | |
...state, | |
patching: true, | |
patched: false, | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment