vendredi 21 août 2020

React UseState Boolean Array Modify One Element

I have a boolean array in useState

const [checkBoxState, setcheckBoxState] = useState([true,true,true,true,true,......]

I need a function that toggle only specific index value A function like this

const HanldeCheck = (index) => {
    setcheckBoxState[index] = !checkBoxState[index];
  };

Please Help




Aucun commentaire:

Enregistrer un commentaire