'In a SectionList how do i hide the section header of an empty section (data:[])

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.



Solution 1:[1]

<SectionList>
    renderSectionHeader={({ section: { title, data } }) =>
            data.length > 0 && <Text>{title}</Text>
            }
    ...
</SectionList>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Soyal7