Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.

Commit dd6ad91

Browse files
committed
guard against codePushDownloadDidProgress(...) or codePushStatusDidChange(...) not being defined
1 parent 81e0f13 commit dd6ad91

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

CodePush.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,15 @@ function codePushify(options = {}) {
428428
CodePush.notifyAppReady();
429429
} else {
430430
let rootComponentInstance = this.refs.rootComponent;
431-
let syncStatusCallback = rootComponentInstance && rootComponentInstance.codePushStatusDidChange.bind(rootComponentInstance);
432-
let downloadProgressCallback = rootComponentInstance && rootComponentInstance.codePushDownloadDidProgress.bind(rootComponentInstance);
431+
if (rootComponentInstance && rootComponentInstance.codePushStatusDidChange) {
432+
syncStatusCallback = rootComponentInstance.codePushStatusDidChange.bind(rootComponentInstance);
433+
}
434+
435+
let downloadProgressCallback;
436+
if (rootComponentInstance && rootComponentInstance.codePushDownloadDidProgress) {
437+
downloadProgressCallback = rootComponentInstance.codePushDownloadDidProgress.bind(rootComponentInstance);
438+
}
439+
433440
CodePush.sync(options, syncStatusCallback, downloadProgressCallback);
434441
if (options.checkFrequency === CodePush.CheckFrequency.ON_APP_RESUME) {
435442
ReactNative.AppState.addEventListener("change", (newState) => {

0 commit comments

Comments
 (0)