我正在从平面列表迁移到闪存列表,我已经将世博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函数
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())
);
手电筒
<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>
发布于 2022-09-14 20:39:02
我有同样的问题,一个警告FlashList rendered size is not useable
和屏幕是空白的。
根据FlashList文档,我们应该在包装器(如View
)中使用它,并使用硬编码的高度样式编号,如下所示:
<View style={{ height: 200, width: Dimensions.get("screen").width }}>
<FlashList
data={DATA}
renderItem={({ item }) => <Text>{item.title}</Text>}
estimatedItemSize={200}
/>
</View>
如果我在你的立场,我会使一个简单的闪光灯完美地工作,然后我会实现我想要的列表,并添加更多。
这解决了我的问题。希望你能成功。
发布于 2022-10-03 15:59:57
如果将FlashList放在带有justifyContent=center和alignItem=center的视图中,则应该会收到此错误。试着像这样删除它:
<View style={{flex: 1}}>
<FlashList data={must not empty} ... />
</View>
https://stackoverflow.com/questions/73516978
复制相似问题