jeudi 4 mars 2021

checkbox react-native on api array

These checkboxes are working returning the values correctly, the problem is that after selecting the first one, I need to click 3 times on the one I want to select to be marked

function onChecked(id,valor){
    const data = adc
    const index = data.findIndex(x => x._id === id)
    data[index].checked = !data[index].checked

    
    setCheck(data[index].checked)

    //alert(valor)
}
...
<TouchableOpacity key={a._id} onPress={() => {this.onChecked(a._id)}} style=>
                                        <CheckBox value={a.checked} onValueChange={() => {onChecked(a._id,a.valorA)}}/>
                                    </TouchableOpacity>

the rest works normally only when checking this problem




Aucun commentaire:

Enregistrer un commentaire