You need to recreate the items object, with active set to false
for the items that do not match the clicked items.
case actionTypes.SET_ACTIVE:
const editItem = accounts.map((item)=> item.id !== action.id ? {...item,active: false} : {...item,active: true})
console.log(editItem)
return {
...state,
accounts: editItem
}
default:
return state;
}
PS: If possible , you should maintain a local state for each of your checkboxes and set that via a toggle function and then at some later point you want to dispatch. I dont know, how you designed the application , but just an additional suggestion!
CLICK HERE to find out more related problems solutions.