How to update value array in object React js I want update value checked by name .....................................................................................................................................................................................................................................................................................................
const [state, setState] = React.useState([{
name: "box",
checked: false,
},{
name: "box1",
checked: false,
}]);
const checkboxhandleChange= (event) => {
setState({ ...state, [event.target.name]: event.target.checked });
};
statefrom an array to an object. You're kindof mixing syntax from the traditional class basedsetStatewith the hooks equivalent.