By using extraData
property on the FlatList
component.
<FlatList
data={data }
style={FlatListstyles}
extraData={this.state}
renderItem={this._renderItem}
/>
By passing extraData={this.state}
to FlatList
we make sure FlatList
will re-render itself when the state.selected
changes. Without setting this prop, FlatList
would not know it needs to re-render any items because it is also a PureComponent
and the prop comparison will not show any changes.