ListView removing wrong row on dataSource update

后端 未结 1 1501
死守一世寂寞
死守一世寂寞 2020-12-06 13:19

I have a React Native ListView that seems to be removing the wrong row in the UI when I update the state with the new sections & rows - The row I deleted stays, but the

相关标签:
1条回答
  • 2020-12-06 14:00

    I'm not sure if this is the proper answer, but it's worked for me until I can find a better explanation/better answer.

    I recently had this same question, as did someone else I was talking to. They fixed it by adding a key property to the ListView. Apparently, you need to add key to ListView because the table rows are super dynamic, and it seems like not having the key on each row was causing ListView to incorrectly choose what row to get deleted.

    <ListView
      key={putSomethingUniqueInHere}
      dataSource={this.state.dataSource}
      renderRow={this.renderRow.bind(this)}
    />
    
    0 讨论(0)
提交回复
热议问题