Reputation: 40
I have a Redux reducer:
case inputTypes.CLEAR_INPUTS:
const defaultCopyTwo = JSON.parse(JSON.stringify(defaultInput))
return {
...state,
inputs: {
0: defaultCopyTwo
}
};
The logic that I'd like to have happen is that the 0th index of the inputs object gets reset to the defaults, but that the other indices don't get deleted. Currently, everything is getting cleared - not just the 0th index.
Upvotes: 0
Views: 34
Reputation: 18249
I think this change should work as you intend?
return {
...state,
inputs: {
...state.inputs,
0: defaultCopyTwo
}
};
Upvotes: 1