As far as I can tell, when I sort the dataSource and then call dataSource.cloneWithRows, it thinks nothing has changed, and thus does not rerender the ListView.
Some background:
I fetch some data, which returns: [{price: 10}, {price: 9}...]. After which i set the state with the new data: this.setState({dataSource: this.state.dataSource.cloneWithRows(data)}). Lets pretend this data is completely sorted. If i reverse the data and set the state, it will not rerender: this.setState({dataSource: this.state.dataSource.cloneWithRows(data.reverse())})
BUT: After messing around a bit, i made a change to the dataSource, like so:
// getInitialState...
dataSource: new ListView.DataSource({
rowHasChanged: (row1, row2) => true,
}),
...which I know is hackery... But now I can toggle reverse back and forth and it works!
Am I missing something here? Or is this perhaps a side effect of the ListView's optimizations?
As far as I can tell, when I
sortthedataSourceand then calldataSource.cloneWithRows, it thinks nothing has changed, and thus does not rerender theListView.Some background:
I fetch some data, which returns:
[{price: 10}, {price: 9}...]. After which i set the state with the new data:this.setState({dataSource: this.state.dataSource.cloneWithRows(data)}). Lets pretend this data is completely sorted. If i reverse the data and set the state, it will not rerender:this.setState({dataSource: this.state.dataSource.cloneWithRows(data.reverse())})BUT: After messing around a bit, i made a change to the dataSource, like so:
...which I know is hackery... But now I can toggle
reverseback and forth and it works!Am I missing something here? Or is this perhaps a side effect of the
ListView's optimizations?