renderSectionHeader docs not very clear
See original GitHub issueI’m trying to create Instagram photo like sticky headers, but I don’t understand how to structure the data. I’ve seen examples like these:
dataSource : new ListView.DataSource({
getSectionData : getSectionData,
getRowData : getRowData,
rowHasChanged : (row1, row2) => row1 !== row2,
sectionHeaderHasChanged : (s1, s2) => s1 !== s2
})
and
dataSource : this.state.dataSource.cloneWithRowsAndSections(dataBlob, sectionIDs, rowIDs)
but I can’t figure out how they work…
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Render 'no content' component when section in SectionList ...
I know for the FlatList component this is possible using the ListEmptyComponent prop, but how does this work for the SectionList component? I ......
Read more >ListView · React Native
Called when all rows have been rendered and the list has been scrolled to within onEndReachedThreshold of the bottom. The native scroll event...
Read more >Text - React Native - W3cubDocs
The <Text> element is unique relative to layout: everything inside is no longer using the Flexbox layout but using text layout. This means...
Read more >SectionList - React Native
SectionList. A performant interface for rendering sectioned lists, supporting the most handy features: Fully cross-platform.
Read more >Sticky Headers Example - NativeBase
We do not want to display it as a list item. Similarly we implemented renderSectionHeader function, returning section headers, as shown above. Wrapping...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ok I figured it out.
First I put this in my constructor function:
Then you have to create a dataBlob object, an array of sectionIDs, and an array of rowID arrays with the following formats:
Finally, you can create a valid dataSource for your list with:
Hope this helps someone else.
@syousif94 Man, now I have to thank you again. I just replaced my convoluted ListView with SectionList and it’s way easier to use. It’s less than half the code required for ListView.
Thanks for the pointer! 🙏