react checkbox无法选中 但是state已经发生变化

因为checkbox是动态生成的,是react-native-table-component组件里面的一个元素,如果我只改变checkbox的state 不会生效,要改变整个table的state才可以

let aaa = [];

const index2 = index + 1;

aaa.push(<CheckBox

// checked={this.state[index]}

key={index}

name='secotr'

square={true}

rgb(231,231,231)' }}

// onPress={()=> {

// //this._onPress()

// this.setState({

// //[index]:!this.state[index]

// checked:true

// })

// }}

checked={val.checked}

onPress={(e) => this.toggleSwitch3(index, e)}

/>);

toggleSwitch3(index, e) {

console.log(e.target.checked, 'eeeeeeeeeeeeeeeeeeeeeeeeeee')

let sectorName="";

if (this.state.item && this.state.item.sectors) {

this.state.item.sectors.map((row, index1) => {

if (index1 == index) {

this.state.item.sectors[index1].checked = true;

sectorName = this.state.item.sectors[index].sectorName

} else {

this.state.item.sectors[index1].checked = false;

}

});

}

this.setState({

//[index]: !this.state[index],

SECTOR_ID: sectorName,

checked: true

});

this.updateSectors(this.state.item);

}

this.state.item里面存的就是table里面的tabledata

所以如果改变动态组件里面的state必须要重新绘制整个组件才会生效