I have a FlatList which is sourced by an array defined in the view's state. The list is filtered by filtering the original array and setting the array in the state with the new filtered array. But the re-render is only called when the list is scrolled. Is there a way to force re-render flatlists ?
import setsArr from '../../json/sets';
.
.
.
constructor (props) {
super(props);
this.state({
arrToDisplay: setsArr,
});
}
.
.
.
_filter = (filter,value) => {
var newArr = setsArr.filter(function(){
return (el.filter === value)
});
this.setState({
arrToDisplay: newArr,
});
}
renderOption = (data) => {
return (
<Text>{data.item.name}</Text>
);
}
render () {
return (
.
.
.
<FlatList
data={this.state.arrToDisplay}
renderItem={(item) => this.renderOption(item)}}/>
.
.
);
}