React-native FlatList not rerendering row when props change

后端 未结 7 612
闹比i
闹比i 2021-02-01 14:33

I\'m having an issue with the new FlatList component. Specifically, it does not rerender it\'s rows, even though props that the row is dependent on changes.


The F

7条回答
  •  情深已故
    2021-02-01 15:15

    I agree with Nimelrian. Also, If your state is an Array you could create an Array Object from the state by doing:

     var oldReportCopy = Object.assign([], this.state.report);
    

    Then use the .push() method to add your new object to it like this:

    oldReportCopy.push(selectedCategory);
    

    you can then set this new Array Object back to state:

    this.setState({ report: oldReportCopy });
    

提交回复
热议问题