I have three checkboxes and I would like to push the value to the equipment array in the below hook e.g.: if 2 boxes ticked the array should look like:
equipment: [{id: '1', name: 'bag', amount: 1}, {id: '2', name: 'phone', amount: 4}]
const [form, setForm] = useState({
firstName: "",
lastName: "",
middleName: "",
position: "",
level: "",
equipment: []
});
Is it a proper way to update the array or how should I do it with spread?
setForm({...form, ...form.equipment.push(value)}