React-Native Updating List View DataSource
Try this:
pressRow(rowData){
var newDs = [];
newDs = this.state.ds.slice();
newDs[0].Selection = newDs[0] == "AwayTeam" ? "HomeTeam" : "AwayTeam";
this.setState({
dataSource: this.state.dataSource.cloneWithRows(newDs)
})
}
This should make a copy of the array, which can then be modified independently of the original array in this.state.ds
.
Can't update dataSource with ListView on React-Native
Managed to fix it with one of the previous answers listed here with a slight tweak:
_getCoinData() {
getCryptocurrencyData().then(function(result) {
const ds = new ListView.DataSource({rowHasChanged: (row1, row2) => row1 !== row2});
this.setState({
dataSource: ds.cloneWithRows(result),
jsonData: result
});
console.log('!!!', this.state.jsonData);
}.bind(this))
}
React Native: ListView.DataSource is not updating
In your code, you only set your dataSource
in contructor
of FormativeRevisionList
, this mean FormativeRevisionList
will only render the given movies when your first render it.
To render new list after you press Get Topics button , you need to set the dataSource
again when it receive new props, this can be achieve by setting it in FormativeRevisionList componentWillReceiveProps
componentWillReceiveProps(nextProps) {
if (nextProps.movies !== this.props.movies) {
this.setState({
dataSource: this.state.dataSource.cloneWithRows(nextProps.movies)
})
}
}
You can read more about componentWillReceiveProps from here
react native ListView datasource not updating
So after a lot of reading and changes the listview is now updating.
According to this post
Changes the ds declaration to:
this.ds = new ListView.DataSource({rowHasChanged: (row1, row2) => row1 !== row2});
So changed my changeisComplete method
changeisCompleted=(rowData,rowId)=>{
var newDs = [];
newDs = this.state.todoListArray.slice();
newDs[rowId].isCompleted =!newDs[rowId].isCompleted;
this.setState({
dataSource: this.ds.cloneWithRows(this.state.todoListArray),
todoListArray:newDs
})
}
I'm not sure if this is the right way to do this,but anyway it works and now the checkbox is getting changed
Thanks
Related Topics
Build JavaScript Object to Use with Jquery .Css() (What About Duplicate Keys)
Jquery Tablesorter CSS Arrow Icons
Displaying a Div Only on Tumblr Blog Homepage
Using !Important in Jquery's CSS() Function
Make :Focus Change CSS of Another Class
Avoid Having to Double-Click to Toggle Bootstrap Dropdown
JavaScript Not Working in Android Webview
Isotope Jquery Plugin Doesn't Show Properly on Chrome
After Content Update from Ajax Jquery Not Work Properly
Bootstrap Dropdown Checkbox Select
How to Enable the JavaScript Error/Debug Console for Safari Within Android
Alert, Confirm, and Prompt Not Working After Using History API on Safari, iOS
Handling JavaScript Events in Wkwebview
Android Webview, Loading JavaScript File in Assets Folder