FlatList ScrollView Error on any State Change - Invariant Violation: Changing onViewableItemsChanged on the fly is not supported

前端 未结 7 1250
北荒
北荒 2020-12-31 10:11

onViewableItemsChanged does not seem to work when there is a state change in the app. Is this correct?

Seems like it wouldn\'t be very useful if this

7条回答
  •  隐瞒了意图╮
    2020-12-31 10:32

    Sombody suggest to use extraData property of Flatlist to let Flatlist notice, that something changed.

    But this didn't work for me, here is what work for me:

    Use key={this.state.orientation} while orientation e.g is "portrait" or "landscape"... it can be everything you want, but it had to change, if the orientation changed. If Flatlist notice that the key-property is changed, it rerenders.

    works for react-native 0.56

提交回复
热议问题