简体   繁体   English

Flatlist React Native-无数据显示

[英]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.

相关问题 如何在FlatList React Native中显示JSON数据 - How to display JSON data in FlatList React Native 如何在React Native中使用FlatList显示数据? - How to display data using FlatList in react native? REACT NATIVE:如何在 FlatList 中显示数据? - REACT NATIVE : How can i display the data in FlatList? 为什么 firebase 数据没有通过在 react native 中使用 flatlist 显示在屏幕上 - why firebase data is not display on screen by using flatlist in react native 无法在Flatlist react-native上显示json数据 - Not able to display json data on Flatlist react-native 如何从 API 中过滤特定数据并将其显示在 React Native Flatlist 中? - How to filter specific data from API and display it in React Native Flatlist? 如何在 React Native 中将 firebase 中的用户特定数据显示为 FlatList - How to display user specific data from firebase as a FlatList in React Native 如何在 React Native 中使用 FlatList 和 webView 显示数据? - How to display data using FlatList and webView in react native? React Native fetching GeoFire 并且只能在 flatlist 中显示一个数据 - React native fetching GeoFire and only one data can display in flatlist 如何将 Firestore 中的这些数据显示到我的 React Native Flatlist 中 - How to display this data from Firestore into my React Native Flatlist
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM