componentDidMount() {
this.onRefresh(this.props.subdomainConfig)
}
onRefresh = config => () => {
console.log('onRefresh', config)
}
在这个反应组件中,当组件安装时,onRefresh 函数根本不会被调用。如果我将此函数用于 RefreshControl,那么它将被调用。
<ScrollView
refreshControl={
<RefreshControl
refreshing={this.state.refreshing}
onRefresh={this.onRefresh(this.props.subdomainConfig)}
/>
}>
<ZoneListComponent
zones={zones}
onPressEdit={this.onPressEdit}
/>
</ScrollView>
感谢有人能告诉我为什么这没有在 componentDidMount 中被调用,而是适用于 RefreshControl。