React Native reload page

后端 未结 4 2050
情深已故
情深已故 2020-12-31 11:05

So I have an app with an activity. The app checks for Internet connection at the beginning. If there are no Internet connection, it will show a screen with a button to refre

4条回答
  •  傲寒
    傲寒 (楼主)
    2020-12-31 11:41

    I would suggest putting your API call in it's own function fetchData within your component. fetchData can also setState after a successful fetch which will cause a re-render and show the fresh data. If you want to fetch fresh data on componentDidMount and also on a button click, then create a fetchData function and call that from within componentDidMount, then for your button just set your onPress prop appropriately onPress={this.fetchData}

提交回复
热议问题