How to update array state in react native?

前端 未结 4 1850
無奈伤痛
無奈伤痛 2020-12-05 13:56

I am trying to update only one element in an array state but i am not sure of how to do it.

State

constructor(props) {
    super(pro         


        
4条回答
  •  一整个雨季
    2020-12-05 14:36

    Try this using create function

    onEditComparatorClicked(i) {
       let editableComparatorIndexes = [...this.state.markers];
       editableComparatorIndexes[i] = 1;
       this.setState({editableComparatorIndexes});
    }
    

提交回复
热议问题