Flatlist React Native - 无数据显示
问题描述:
我们正在使用Flatlist开发反应本机应用程序。绑定数据来自API服务&其工作正常。假设没有可用的数据,我们需要为此显示单独的设计。Flatlist React Native - 无数据显示
我们使用“renderEmptyListComponent”为
共享代码,请
<FlatList style={{ backgroundColor: 'white' }}
data={this.state.dataSource}
renderItem={({ item }) => (this.renderMovie(item))}
keyExtractor={item => item.salesID}
renderEmptyListComponent= {this.noItemDisplay}
ItemSeparatorComponent={this.renderSeparator}>
</FlatList>
请指导我如何才能做到这一点?
答
可能要改用这一点:
<FlatList
style={{ backgroundColor: 'white' }}
data={this.state.dataSource}
renderItem={({ item }) => (this.renderMovie(item))}
keyExtractor={item => item.salesID}
ListEmptyComponent={this.noItemDisplay}
ItemSeparatorComponent={this.renderSeparator}>
</FlatList>
或者如果也不起作用做旧三元JSX-eroo
{ this.data ? <FLatList /> : null }
希望这有助于
有没有这样的道具“renderEmptyListComponent”。根据文档,它是 “ListEmptyComponent”。 http://facebook.github.io/react-native/releases/0.47/docs/flatlist.html#flatlist – Dev