I am working on a react project and using redux for state management.I want to update values in an array using index but initially the array is empty.
How can I do it?
I am doing this:
case Actions.UPDATE:
return {
...state,
defaultCodeList: state.defaultCodeList.map((code, index) => (index === action.index ? {
code_sys_id: state.masterName, code_sys_cat_id: state.codeSystem, [`${state.codeSystem}_description`]: action.description,
} : codeset)),
};
Initailly defaultCodeList:[] and on pressing of a button I am triggering this action.
I want to put the above object on that particular index when the index matches.
Any leads on this?