How to determine if React Native ListViewDataSource is empty?

I pass ListViewDataSourcedown as a prop and want the child to detect if it is empty or not.

Debugging in Chrome, I see that the property _cachedRowCountmatters 0when the list is empty.

Is there a better way to determine if a list view is empty?

+4
source share
1 answer

Try getRowCount()for example:

let ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});
let dataSource = ds.cloneWithRows(this.state.rows || [])

console.log(dataSource.getRowCount())
+19
source

Source: https://habr.com/ru/post/1624766/


All Articles