title: Update state on successful update with code push
body: <p>I'm using code-push to update my react-native app. I don't want to upload it to App Store every time if I make an update, I want to push it directly to the users device.</p>
  
  <p>It works fine, the app is updated but I'm trying to show an notification if the updated is successful.    </p>
  
  <p>In the <a href="https://github.com/Microsoft/react-native-code-push/blob/master/docs/api-js.md#codepushsync" rel="nofollow noreferrer">docs</a> they are doing it as follows:</p>
  
  <pre><code>codePush.sync({ updateDialog: true },
    (status) =&gt; {
        switch (status) {
            case codePush.SyncStatus.DOWNLOADING_PACKAGE:
                // Show "downloading" modal
                break;
            case codePush.SyncStatus.INSTALLING_UPDATE:
                // Hide "downloading" modal
                break;
        }
    },
    ({ receivedBytes, totalBytes, }) =&gt; {
      /* Update download modal progress */
    }
  );
  </code></pre>
  
  <p>I'm trying to update the state if the update is successful and show the modal, with an button to hide it on click. Thus my code is as follows:</p>
  
  <pre><code>constructor() {
          super();
          this.state = {
              modalVisible: false,
              status: ""
          }
      }
  
      componentDidMount() {
          let self = this;
          codePush.sync({
                  updateDialog: true,
                  installMode: codePush.InstallMode.IMMEDIATE
              }, (status) =&gt; {
                  switch (status) {
                      case codePush.SyncStatus.UPDATE_INSTALLED:
                          self.setState({modalVisible: true});
                          break;
                  }
              },
              ({receivedBytes, totalBytes,}) =&gt; {
                  /* Update download modal progress */
                  self.setState({status: "Downloaded " + receivedBytes + " of " + totalBytes});
              }
          );
      }
  
      renderUpdateNotificationModal(){
          return (
              &lt;Modal
                  animationType={"slide"}
                  transparent={false}
                  visible={this.state.modalVisible}
                  onRequestClose={() =&gt; {alert("Modal has been closed.")}}
              &gt;
                  &lt;View style={{marginTop: 22}}&gt;
                      &lt;View&gt;
                          &lt;Text&gt;Updated&lt;/Text&gt;
                          &lt;TouchableHighlight onPress={() =&gt; {this.setState({modalVisible: false})}}&gt;
                              &lt;Text&gt;OK&lt;/Text&gt;
                          &lt;/TouchableHighlight&gt;
                      &lt;/View&gt;
                  &lt;/View&gt;
              &lt;/Modal&gt;
          )
      }
  
      render() {
          return (
              &lt;View style={styles.container}&gt;
                  {this.renderUpdateNotificationModal()}
                  &lt;Text style={styles.welcome}&gt;
                      Welcome!
                  &lt;/Text&gt;
                  &lt;Text style={styles.instructions}&gt;
                      To get started, edit index.ios.js
                  &lt;/Text&gt;
                  &lt;Text style={styles.instructions}&gt;
                      Press Cmd+R to reload,{'\n'}
                      Cmd+D or shake for dev menu
                  &lt;/Text&gt;
                  &lt;Text style={{fontSize: 18, marginTop: 15, color: "blue", textAlign: "center"}}&gt;{this.state.status}&lt;/Text&gt;
              &lt;/View&gt;
          );
      }
  </code></pre>
  
  <p>But the problem is that the modal is shown for a few seconds and then it disappears, without clicking on the button.</p>
  
  <p>As the state is set to true, and then after I few seconds to false in </p>
  
  <pre><code>case codePush.SyncStatus.UPDATE_INSTALLED:
       self.setState({modalVisible: true});
       break;
  </code></pre>
  
  <p>Any idea how to solve it?</p>