首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >FlashList的呈现大小不可用

FlashList的呈现大小不可用
EN

Stack Overflow用户
提问于 2022-08-28 07:59:58
回答 2查看 1.5K关注 0票数 4

我正在从平面列表迁移到闪存列表,我已经将世博sdk从45.0.0升级到了46.0.0,在实现闪存列表时,我得到了下面的警告" 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.,它对平面列表很好,只是从api加载数据需要花费很多时间,这就是为什么我决定切换到flashlist.Anyone,知道如何修复这个问题吗?这里有我的代码是非常感谢的

renderItem函数

代码语言:javascript
运行
复制
const renderItem = ({ item: product }) => {
return (
  <Product
    category={product.bp_product_category}
    itemname={product.bp_product_name}
    price={product.bp_product_selling_price}
    mass={product.bp_product_mass}
    unitofmass={product.bp_product_unit_of_mass}
    productID={product._id}
  />
);
};


  const keyExtractor = useCallback((item) => item._id, []);
  const filteredproducts = products.filter((product, i) =>
  product.bp_product_name.toLowerCase().includes(search.toLowerCase())
   );

手电筒

代码语言:javascript
运行
复制
<View style={{flex:1, width:'100%', height:'100%'}} >
       <FlashList
      keyExtractor={keyExtractor}
      data={filteredproducts}
      renderItem={renderItem}
      estimatedItemSize={200}
      numColumns={2}
      refreshing={refresh}
      onRefresh={Refresh}
      contentContainerStyle={{
        // alignSelf: "flex-start",
        // justifyContent: "space-between",
        // paddingBottom: 120,
      }}
    />
    </View>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-09-14 20:39:02

我有同样的问题,一个警告FlashList rendered size is not useable和屏幕是空白的。

根据FlashList文档,我们应该在包装器(如View )中使用它,并使用硬编码的高度样式编号,如下所示:

代码语言:javascript
运行
复制
<View style={{ height: 200, width: Dimensions.get("screen").width }}>
    <FlashList
       data={DATA}
       renderItem={({ item }) => <Text>{item.title}</Text>}
       estimatedItemSize={200}
    />
</View>

如果我在你的立场,我会使一个简单的闪光灯完美地工作,然后我会实现我想要的列表,并添加更多。

这解决了我的问题。希望你能成功。

票数 3
EN

Stack Overflow用户

发布于 2022-10-03 15:59:57

如果将FlashList放在带有justifyContent=center和alignItem=center的视图中,则应该会收到此错误。试着像这样删除它:

代码语言:javascript
运行
复制
<View style={{flex: 1}}>
    <FlashList data={must not empty} ... />
</View>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73516978

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档