React-Native:在ios中传递空数组时,Flatlist和Sectionlist引发异常

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了React-Native:在ios中传递空数组时,Flatlist和Sectionlist引发异常相关的知识,希望对你有一定的参考价值。

以下是我的Flatlist代码,

 <FlatList
      data={allRequestsArr}
      renderItem={({ item, index }) => this.renderItems(item, index)}
      keyExtractor={item => item.id.toString()}
      onEndReached={this.loadMore}
      onEndReachedThreshold={0.1}
      ListFooterComponent={this.renderFooter}
      initialNumToRender={allRequestsArr.length}
      ListEmptyComponent={this.renderEmptyResultContent}
 />

[allRequestsArr是并且为空数组时,出现以下异常,

enter image description here

仅在ios中同时发生[FlatlistSectionList都发生。在android中,通常会调用ListEmptyComponent

任何人都可以让我知道代码出了什么问题吗。谢谢!

答案

如果它是一个空数组,则不会引发任何错误,问题是传递的值未定义或NAN,

以上是关于React-Native:在ios中传递空数组时,Flatlist和Sectionlist引发异常的主要内容,如果未能解决你的问题,请参考以下文章