To set up our ListView to accommodate section headers, we need to make some modifications to the way we've been creating ListViews.
First, when we instantiate a new ListView DataSource, we'll be passing it a second callback, sectionHeaderHasChanged. Like rowHasChanged, this one checks to see whether a section header has changed. In your code, it looks something like this:
this.state = { ds: new ListView.DataSource({ rowHasChanged: (r1, r2) => r1 !== r2, sectionHeaderHasChanged: (s1, s2) => s1 !== s2 }), }
Then, instead of calling cloneWithRows, we call the similarly named cloneWithRowsAndSections function:
const dataSource = this.state.ds.cloneWithRowsAndSections(this.state.listOfExpenses);
Finally, ...