I'm using react-native's SectionList and can't hide the sectionheaders of the empty sections of my dataset. I want to show only the section headers and the rows of the sections that are not empty.
Asked
Active
Viewed 4,348 times
6
-
1You should mark @Andre Simon's answer as accepted – Irfan wani Jul 16 '21 at 04:18
2 Answers
20
This is what I did:
<SectionList
renderSectionHeader={({ section }) => (
section.data.length > 0 ? this._renderHeader(section.title) : (null)
)}
...
/>

Andre Simon
- 665
- 10
- 16
0
<SectionList>
renderSectionHeader={({ section: { title, data } }) =>
data.length > 0 && <Text>{title}</Text>
}
...
</SectionList>

Soyal7
- 381
- 5
- 10