According to React Native's ListView documentation, a ListView datasource should be declared with the following standard implementation of rowHasChanged in order determine when the given row has changed:
var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
My question here is: what's the idea behind having to provide such an obvious and trivial implementation of detecting whether or not a row has changed? Are there any cases where this implementation doesn't hold true? I would've imagined that ListViewDataSource would've at least provided a default implementation for such a trivial function instead of having to copy and paste this code every single time we create a datasource.
I can't speak for why there was no default provided but the reason it is available is if you have a list view with complex objects and know a more efficient way to know if a row has changed... for example if all of your list items had an ID property and you knew that if the ID was the same then the entire object was the same you could do:
var ds = new ListView.DataSource({ rowHasChanged: (r1, r2) => r1.id !== r2.id });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With