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

Commit d3a5e84

Browse files
author
Richard Hua
authored
Merge pull request #459 from madsleejensen/master
bind 'this' to the react component in the callbacks codePushStatusDid…
2 parents 759352d + 153ba26 commit d3a5e84

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

CodePush.js

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

0 commit comments

Comments
 (0)