[英]Flatlist React Native - No Data Display
We are developing a react native application using Flatlist. 我们正在使用Flatlist开发一个react native应用程序。 Binding data from API service & its working fine.
绑定来自API服务的数据及其正常工作。 Suppose no data available in service we need to display separate design for that.
假设服务中没有可用的数据,我们需要为此显示单独的设计。
We are using "renderEmptyListComponent" for that 我们为此使用“ renderEmptyListComponent”
sharing the code, please check 共享代码,请检查
<FlatList style={{ backgroundColor: 'white' }}
data={this.state.dataSource}
renderItem={({ item }) => (this.renderMovie(item))}
keyExtractor={item => item.salesID}
renderEmptyListComponent= {this.noItemDisplay}
ItemSeparatorComponent={this.renderSeparator}>
</FlatList>
please guide me how can we do this? 请指导我该怎么做?
might want to use this instead: 可能想改用这个:
<FlatList
style={{ backgroundColor: 'white' }}
data={this.state.dataSource}
renderItem={({ item }) => (this.renderMovie(item))}
keyExtractor={item => item.salesID}
ListEmptyComponent={this.noItemDisplay}
ItemSeparatorComponent={this.renderSeparator}>
</FlatList>
Or if that also doesn't work do the old ternary jsx-eroo 或者,如果这也不起作用,请执行旧的三元jsx-eroo
{ this.data ? <FLatList /> : null }
Hope this helps 希望这可以帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.