samedi 20 novembre 2021

Rendering unchecked checkbox

Well I'm facing a tiny issue with rendering new unchecked checkboxes. Throug an input field I can add tasks as list, each has checkbox & label. Checkbox onChange works fine, but when I add a new task the newly rendered checkbox is checked, which caused obviously by the useState which's been set true after clicking the checkbox, how to reset the state to false and render an unchecked checkbox?

My code:

input type="checkbox" defaultChecked={checked} onChange={handelChange}

const [checked, setChecked] = useState(false);

const handelChange = (e) => {setChecked(!checked)};``




Aucun commentaire:

Enregistrer un commentaire