FlashList 的渲染大小无法与 View Wrapper 一起使用

问题描述 投票:0回答:1

我正在使用

FlashList
,但我有一个
state
控制列表是否显示,我尝试了几种方法,但都给出了相同的结果
FlashList's rendered size is not usable. Either the height or width is too small (<2px). Please make sure that the parent view of the list has a valid size. FlashList will match the size of the parent.

这是我的代码

   <View
          style={{
            minHeight: 9,
            minWidth: 9,
            padding: 9,
          }}
        >
          <FlashList
            keyExtractor={({id}) => id}
            data= cardOpen ? data: []}
            estimatedItemSize={9}
            extraData={cardOpen}
            renderItem={({item}) => (
              <OrderItemComponent item={item} expanded={cardOpen} />
            )}
          />

有人吗?

react-native flash-list
1个回答
0
投票

按照 FlashList 文档,我们应该在具有硬编码高度样式数字的视图中使用它,如下所示:

<View style={{ height: Dimensions.get("screen").height-100, width: Dimensions.get("screen").width }}>
    <FlashList
       ...
    />
</View>
© www.soinside.com 2019 - 2024. All rights reserved.