【发布时间】:2019-01-05 06:05:58
【问题描述】:
我有一个Flatlist,我在该渲染函数中调用其他函数
otherFunc(){
alert('some thing')
}
item(data){
return(
//...something..
{this.otherFunc()} <<<<<<<<<problem is here...its undefined
);
}
render() {
<FlatList
ref={ref => this.scrollView = ref}
data={this.state.foods}
extraData={this.state}
keyExtractor={this._keyExtractor}
renderItem={this.Item}
horizontal
onEndReached={(x) => { this.loadMore() }}
onEndReachedThreshold={0.5}
/>
}
我在this.Item 中返回了一些东西,它们在Flatlist 中呈现得很漂亮,但我不能在this.item 中调用我的组件的其他函数!我什至无法在其中指出this.props.navigation 或任何其他this 关键字。我得到未定义的对象错误。
【问题讨论】:
标签: javascript android ios typescript react-native