reactjs - 反应原生水平平面列表崩溃
问题描述
我正在使用 react native flatlist 在我希望将 flatlist 设置为水平的 react native flatlist 中呈现一些数据。对于要渲染的数据,我创建了一个单独的函数并在我的平面列表中调用它。我的渲染项中有一些图像和文本,现在问题是当我只渲染文本时它似乎工作正常,但是当我添加图像时它崩溃了。下面是我的渲染项:
renderOtherBannerItem =(childItem, index)=>(
<TouchableOpacity
onPress={this.onClickListenerForImageCategoryBrandProductBanner.bind(this, childItem)}
style={{
width: childItem.width,
height: childItem.height,
padding: 3,
}}>
{childItem.numColumns == 1 ? (
<Image
style={{
flex: 1,
shadowColor: "#000",
shadowOffset: {
width: 0,
height: 1,
},
shadowOpacity: 0.18,
shadowRadius: 1.0,
elevation: 1,
width: "100%",
borderRadius: 4,
height: childItem.height,
resizeMode: "stretch",
}}
source={{ uri: childItem.img }}
/>)
我在里面叫它:
<FlatList
style={{ marginBottom: 20 }}
numColumns={numColumns}
data={bannerViewList}
keyExtractor={(item) => item.key}
renderItem={({ item, index }) => this.renderOtherBannerItem(item, index)}
/>;
谁能告诉我在渲染函数中做错了什么,任何线索都会很棒。谢谢你。
解决方案
推荐阅读
- c++ - 我可以简化这个 std::list 的数量吗?
- python - 获得k-倒数最近邻
- python - 在 PonyORM 中找不到反向属性
- javascript - 如何使用 chat.postmessage 作为工作区用户发布松弛消息?
- asp.net - 根据某些条件更改网格视图值
- javascript - React native 不能通过命令在 ios 中运行,但可以在 Xcode 中运行?
- javascript - 在 Angular 组件类中调用自定义 jQuery 函数
- kdb - 在q kdb中获取上一季度的最后一个工作日和第一个工作日(工作日)
- java - 当提供的输入不是数字时,如何使代码捕获错误?
- javascript - 如何为旭日形上的每个节点分配不同的颜色?