当前,我试图找到一个来自上一个API调用的数据之后的方法,而我想根据该API的其余数据,根据前一个API数据进行其余的调用。 问题:我无法通过reducer调用 ComboBoxOptionsUtil 方法。另外,我不确定如何为方法连接redux。
代码在这里: // Reducer.js
export function controlReducer(state = null,action) {
switch (action.type) {
case 'FIND_CONTROL_REQUEST':
return { ...state,isLoading: true };
case 'FIND_CONTROL_SUCCESS':
//Here I am calling a utils method to invoke some other API calls based on data
ComboBoxOptionsUtil(action.data);
return {
...state,isLoading: false,isError: false,dateFetched: new Date(),data: action.data,};
case 'FIND_CONTROL_FAILURE':
.....
default:
.....
}
}
// util.js
function ComboBoxOptionsUtil(controls,{ getReferenceCodes,getLinkedDropDownValues }) {
controls.map(item => {
........
.........
getReferenceCodes();
getLinkedDropDownValues();
});
}
export function mapDispatchToProps(dispatch) {
return {
getReferenceCodes: () => dispatch(getReferenceCodesRequest()),getLinkedDropDownValues: () =>
dispatch(getLinkedDropDownValuesRequest()),};
}
const withConnect = connect(mapDispatchToProps);
export default compose(
withConnect,memo,)(ComboBoxOptionsUtil);