- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
使用 React Native 时,FlatList 组件存在一些问题。
这是我的 FlatList
<FlatList
data={this.state._data}
renderItem={() => this.renderItem()}
refreshControl={
<RefreshControl
onRefresh={() => this.handleRefresh}
refreshing={this.state.refreshing}
/>
}
/>
renderItem({item, index}) {
return (
<View style={{marginTop: 10, marginHorizontal: 10, paddingLeft:
10}}>
<ListItem
roundAvatar
title={`${item.itemName}`}
subtitle={`${item.amount}`}
avatar={require('../../../images/logo.png')}
/>
<View
style={{
paddingBottom: 10,
paddingTop: 10,
display: 'flex',
flexDirection: "row",
justifyContent: "space-around",
alignContent: "center"
}}
>
<View style={{ flexDirection: "row", alignContent:
"center", width:"45%"}}>
<Button
block
small
// disabled={this.state.acceptButtonGray}
style=
{this.state.acceptButtonGray ? ({
backgroundColor: 'gray',
width: "100%"
}) : ({backgroundColor: "#369ecd",
width: "100%"
})}
onPress={() =>
this.setState({
modalVisible: true,
// acceptOrDeclineModalText: `Accept offer for ${item.amount} ${'\b'} Are you Sure?`,
acceptOffer: true,
})
}
>
<Text>
Accept
</Text>
</Button>
</View>
</View>
</View>
);
}
TypeError: Cannot read property 'item' of undefined.
renderItem={this.renderItem}
_this2.setState is not a function
最佳答案
你应该写一个这样的renderItem函数
renderItem = ({item, index}) => {
// return here
}
关于react-native - React Native Flatlist renderItem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47934816/
我正在使用 FlatList 显示来自 API 调用的数据: render() { const { navigation } = this.props; const animating = t
问题是我在函数内看不到 {item.key} 。当我在平面列表渲染中输入 {item.key} 本身时,它正在工作。但在函数内部仅显示 {item.value} 。谁能向我解释为什么会发生这种情况?
我以前在 JS 中见过这种语法,我只是好奇它是如何工作的。在React Native Docs for FlatList ,一个示例调用 renderItem。 this._renderItem 如何
我在做什么 ? 尝试根据 state.data 中存储的某些项目呈现 FlatList .有一个按钮,按下后会在 state.data 中添加一个新项目. 问题是什么 ? 按下按钮后,我希望仅调用 r
所以我尝试使用 React Native 的 FlatList renderItem 属性,但发生了一些非常奇怪的事情。 data 属性设置为一个包含未定义元素的数组,但是在 renderItem 函
我正在使用 _renderItem 修改结果列表 .data( "autocomplete" )._renderItem = function( ul, item ) { va
我的 React native 应用程序上有一个提要屏幕,它有一个列表组件: } onPressFooter={this.onEndReached} data={this.s
使用 React Native 时,FlatList 组件存在一些问题。 这是我的 FlatList this.renderItem()} refreshControl={
您好,我已经阅读了很多有关此问题的答案并按照说明进行操作,但它对我不起作用。 $(document).ready(function(){ $(".header-search-box").autoc
我正在尝试填充 FlatList屏幕上的自定义组件 (),但是,组件的所有元素都没有显示。例如:title在我的组件中是空白的,而不是终端输出中显示的“测试事件”。 内部componentWillMo
使用: .data( "autocomplete" )._renderItem = function( ul, item ) { var temp = item.url
我正在使用 FlatList,它可以正确显示所有内容。 但是当我更新产品数量时,它只增加了总量,但在 FlatList 的 renderItem 中没有任何变化。 当我按下加号按钮时,总金额发生了变化
我正在尝试使用两种方式呈现数组数据:Normal View 和 FlatList。我了解到,我们在 map 和 renderItem 中传递了 props。 第一个 block 给出正确的输出:
我的组件中有一个函数作为 Prop ,我必须将此函数 Prop 传递给 FlastList 中 renderItem 中的另一个组件。怎么做?这是我的代码。 import React, { Compo
它会在找到的第一个自动完成中正确覆盖,但对其余部分不执行任何操作。相反,它会加载原始的 _renderitem 方法,您可以在 https://github.com/jquery/jquery-ui/
我试图理解 renderItem 和 renderItemData 之间的区别。 我找不到相关文档。 我有以下代码: $.widget( "custom.catcomplete", $.ui.auto
我想为我的 renderItems() 中的每个项目发出一个 get 请求,所以我是这样的: renderItems({ item }) { axios.get(Utilities.url + "
我有一个 FlatList,当使用普通的旧 时,它可以按预期工作。标记,但是在 renderItem 中使用自定义组件时,FlatList 在更改 this.state.dayOfYear 时不会重
我有一个 list 。里面有10个元素。我用 flatlist 来展示这个。但是当列表中 10 个元素中的 1 个发生变化时,它会再次呈现其中的 10 个。我打算用备忘录解决这个问题(flatlist
我尝试了将“autocomplete”重命名为“ui-autocomplete”的解决方案(使用 JQueryUI 1.10.0、JQuery 1.8.3),但仍然收到错误: TypeError: $
我是一名优秀的程序员,十分优秀!