onRefresh function Example
suggest change_refreshListView(){
//Start Rendering Spinner
this.setState({refreshing:true})
this.state.cars.push(
{name:'Fusion',color:'Black'},
{name:'Yaris',color:'Blue'}
)
//Updating the dataSource with new data
this.setState({ dataSource:
this.state.dataSource.cloneWithRows(this.state.cars) })
this.setState({refreshing:false}) //Stop Rendering Spinner
}
This updates the array and then the data source. A real refresh should request data (for example with the Fetch API, including async/await) and set refreshing to false when that request finishes. These two setState calls run immediately, so the spinner may never appear.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents