From dd6ad915b5f7cc4cebebf685a591cfe9daa2be90 Mon Sep 17 00:00:00 2001 From: Mads Lee Jensen Date: Fri, 5 Aug 2016 16:15:00 +0200 Subject: [PATCH] guard against codePushDownloadDidProgress(...) or codePushStatusDidChange(...) not being defined --- CodePush.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/CodePush.js b/CodePush.js index f7ac315..053005f 100644 --- a/CodePush.js +++ b/CodePush.js @@ -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) => {