guard against codePushDownloadDidProgress(...) or codePushStatusDidChange(...) not being defined

This commit is contained in:
Mads Lee Jensen
2016-08-05 16:15:00 +02:00
parent 81e0f13ff9
commit dd6ad915b5

View File

@@ -428,8 +428,15 @@ function codePushify(options = {}) {
CodePush.notifyAppReady();
} else {
let rootComponentInstance = this.refs.rootComponent;
let syncStatusCallback = rootComponentInstance && rootComponentInstance.codePushStatusDidChange.bind(rootComponentInstance);
let downloadProgressCallback = rootComponentInstance && rootComponentInstance.codePushDownloadDidProgress.bind(rootComponentInstance);
if (rootComponentInstance && rootComponentInstance.codePushStatusDidChange) {
syncStatusCallback = rootComponentInstance.codePushStatusDidChange.bind(rootComponentInstance);
}
let downloadProgressCallback;
if (rootComponentInstance && rootComponentInstance.codePushDownloadDidProgress) {
downloadProgressCallback = rootComponentInstance.codePushDownloadDidProgress.bind(rootComponentInstance);
}
CodePush.sync(options, syncStatusCallback, downloadProgressCallback);
if (options.checkFrequency === CodePush.CheckFrequency.ON_APP_RESUME) {
ReactNative.AppState.addEventListener("change", (newState) => {