I am rendering multiple checkboxes:
className, content, visible, handleFeaturesChange}= props;
...
<FormCheck type="checkbox" label={"parking"} name={"parking"} onChange={handleFeaturesChange}></FormCheck>
<FormCheck type="checkbox" label={"Laundry"} name={"laundry"} onChange={handleFeaturesChange}></FormCheck>
from parent component:
function handleFeaturesChange(event) {
// event.preventDefault();
const {name, checked} = event.target
setFeatures({
...features,
[name]: checked
})
}
But this results in state being over-riden onChange so that only one checkbox is recorded as checked in any instance.
How do I get multiple checkboxes to work together?
Aucun commentaire:
Enregistrer un commentaire