React Native reload page

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

    You can force update the component. Check this: https://reactjs.org/docs/react-component.html#forceupdate

    It will re-render the component.

    check this example:

    class App extends Component{
      constructor(){
        super();
            this.forceUpdateHandler = this.forceUpdateHandler.bind(this);
      };
    
      forceUpdateHandler(){
        this.forceUpdate();
      };
    
      render(){
        return(
          

    Random Number : { Math.random() }

    ); } } ReactDOM.render(, document.getElementById('app'));

提交回复
热议问题