0
componentDidMount() {
    this.onRefresh(this.props.subdomainConfig)
}

onRefresh = config => () => {
    console.log('onRefresh', config)
}

In this react component the onRefresh function is not getting called at all when component mounts. If I use this function for RefreshControl then it is getting called.

<ScrollView
    refreshControl={
        <RefreshControl
            refreshing={this.state.refreshing}
            onRefresh={this.onRefresh(this.props.subdomainConfig)}
        />
    }>
    <ZoneListComponent
        zones={zones}
        onPressEdit={this.onPressEdit}
    />
</ScrollView>

Appreciate if someone can tell me why this is not getting called in componentDidMount but works for RefreshControl.

Aman Agarwal
  • 589
  • 1
  • 4
  • 22

1 Answers1

4

onRefresh returns a function but doesn't call it. Change that to

componentDidMount() {
    this.onRefresh(this.props.subdomainConfig)();
}
larz
  • 5,724
  • 2
  • 11
  • 20