ListEmptyComponent isn't working as (I) expected
See original GitHub issueDescription
The footer component get’s displayed even if the sections
prop (of the SectionList) is an empty list and the empty List component never get’s displayed.
Reproduction Steps
I pass down an empty list as a prop (holidays
) and start async fetching the data in a parent component. Once the data is fetched I update the parent component’s state and thereby the props to the child that contains the SectionList
Sample Code
footer() {
return <Text>The End</Text>
}
emptyList() {
return <Text>Fetching</Text>
}
render() {
return (
<SectionList
style={styles.container}
sections={this.props.holidays}
renderItem={this.renderItem.bind(this)}
renderSectionHeader={this.renderSectionHeader.bind(this)}
ListFooterComponent={this.footer.bind(this)}
ListEmptyComponent={this.emptyList.bind(this)}
/>
)
Solution
If it’s a bug then it needs to be fixed. Else the documentation have to be update to be clear (I be gladly to help out).
Additional Information
- react-native-cli: 2.0.1
- react-native: 0.44.0
- Platform: iOS
- Development Operating System: macOS
- Build tools: iOS 10.3
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Showing list empty message at the center of the screen in a ...
I am using React-Native version 0.43.0 which does not support ListEmptyComponent of FlatList. Hence I am using ListHeaderComponent to render ...
Read more >lineHeight in react-native Text component not working as ...
Coding example for the question lineHeight in react-native Text component not working as expected-React Native.
Read more >React Native Show Message for empty Flat List Example - Snack
Example to show message for empty React Native FlatList.
Read more >Showing list empty message at the center of the screen in a ...
I am using React-Native version 0.43.0 which does not support ListEmptyComponent of FlatList. Hence I am using ListHeaderComponent to render a view when...
Read more >rn-extended-flatlist - npm
... with default `ListEmptyComponent` and `ItemSeparatorComponent`. ... function expected by React Native FlatList 's getItemLayout prop.
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 FreeTop 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
Top GitHub Comments
Oh! I’m sorry I haven’t paid attention enough to your additional information… You’re on React Native v0.44, while
ListEmptyComponent
has been added in 0.45.1 😃@hramos @Minishlink I dont understand the point B)
If the sections var is set as follow:
Is there a simple (and intuitive) way to have
SectionList
’s empty rows below of theirs headers? Neither therenderItem
attribute norListEmptyComponent
are triggered to render the empty row. Not working as follow looks like a bug or, at least, looks very confusing…Otherwise, if the
ListEmptyComponent
attribute is not made to create empty rows (but only empty list), maybe another newListEmptyRowComponent
attribute could be set to do the job?The following code can be tested here https://repl.it/N5Vk/46