Skip to content

Commit 8ccc4dc

Browse files
authored
Merge pull request #478 from Microsoft/fix-autobind-warning
Don't bind lifecycle hooks if root component instance is not ES6 declared
2 parents 3994dba + f477c19 commit 8ccc4dc

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

CodePush.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -431,12 +431,18 @@ function codePushify(options = {}) {
431431

432432
let syncStatusCallback;
433433
if (rootComponentInstance && rootComponentInstance.codePushStatusDidChange) {
434-
syncStatusCallback = rootComponentInstance.codePushStatusDidChange.bind(rootComponentInstance);
434+
syncStatusCallback = rootComponentInstance.codePushStatusDidChange;
435+
if (rootComponentInstance instanceof React.Component) {
436+
syncStatusCallback = syncStatusCallback.bind(rootComponentInstance);
437+
}
435438
}
436439

437440
let downloadProgressCallback;
438441
if (rootComponentInstance && rootComponentInstance.codePushDownloadDidProgress) {
439-
downloadProgressCallback = rootComponentInstance.codePushDownloadDidProgress.bind(rootComponentInstance);
442+
downloadProgressCallback = rootComponentInstance.codePushDownloadDidProgress;
443+
if (rootComponentInstance instanceof React.Component) {
444+
downloadProgressCallback = downloadProgressCallback.bind(rootComponentInstance);
445+
}
440446
}
441447

442448
CodePush.sync(options, syncStatusCallback, downloadProgressCallback);

Examples/CodePushDemoApp/demo.js

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class CodePushDemoApp extends Component {
1919
}
2020

2121
codePushStatusDidChange(syncStatus) {
22-
console.log(this.setState);
2322
switch(syncStatus) {
2423
case CodePush.SyncStatus.CHECKING_FOR_UPDATE:
2524
this.setState({ syncMessage: "Checking for update." });

0 commit comments

Comments
 (0)