React Native reload page

后端 未结 4 2074
情深已故
情深已故 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:47

    Remember by calling setState function on your component, you can refresh it. if there's a button that's going to refresh the page, i would do this:

    calling setState will update your component no matter what you object you pass to it. I'm not sure if re-rendering page, calls componentDidMount function, so maybe you need to move your API calls to some funciton func and call this function in your componentDidMount, and also after each button press event. example:

    componentDidMount() {
      apiCalls()
    }
    
    apiCalls() {
       .... // your code
       this.setState({dummy: 1})
    }
    
    render() {
      
        ...
        

提交回复
热议问题