From 392189fad09bd2d243f93c2a3894aa30b06cee4a Mon Sep 17 00:00:00 2001 From: Richard Hua Date: Tue, 11 Oct 2016 17:13:46 -0700 Subject: [PATCH] Support React Native 0.35.0 (#562) * Upgrade example app to RN 0.35.0 * Update supported versions in README * Support RN 35 - make a copy of objects queued over the bridge if they are mutable This line was added in React Native 0.35.0: https://github.com/facebook/react-native/blob/v0.35.0/Libraries/Utilities/MessageQueue.js#L194 (facebook/react-native@145109f). It essentially deep freezes (or makes immutable) any object sent from JS to Native over the bridge. This object is already pass-by-value to begin with, so I assume the purpose of this is to avoid any ambiguity or confusion that might occur if the object is modified while it is sitting in the message queue. We do send a localPackage object over the bridge, which we modify afterwards. Because we only care about the value of this object at the moment that it is queued, the fix is to make a copy of it before sending it over the bridge. This is relevant to issue #536 (RN version support). --- Examples/CodePushDemoApp/package.json | 2 +- README.md | 4 ++-- package-mixins.js | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Examples/CodePushDemoApp/package.json b/Examples/CodePushDemoApp/package.json index 432604c..19fc640 100644 --- a/Examples/CodePushDemoApp/package.json +++ b/Examples/CodePushDemoApp/package.json @@ -8,7 +8,7 @@ "dependencies": { "babel-preset-react-native-stage-0": "1.0.1", "react": "15.3.1", - "react-native": "0.34.1", + "react-native": "0.35.0", "react-native-code-push": "file:../../" } } diff --git a/README.md b/README.md index 90f82d2..0230ba5 100644 --- a/README.md +++ b/README.md @@ -52,8 +52,8 @@ We try our best to maintain backwards compatability of our plugin with previous | v0.19-v0.28 | v1.7.0+ *(introduced Android asset support)* | | v0.29-v0.30 | v1.13.0+ *(RN refactored native hosting code)* | | v0.31-v0.33 | v1.14.6+ *(RN refactored native hosting code)* | -| v0.34 | v1.15.0+ *(RN refactored native hosting code)* | -| v0.35+ | TBD :) We work hard to respond to new RN releases, but they do occasionally break us. We will update this chart with each RN release, so that users can check to see what our "official" support is. +| v0.34-v0.35 | v1.15.0+ *(RN refactored native hosting code)* | +| v0.36+ | TBD :) We work hard to respond to new RN releases, but they do occasionally break us. We will update this chart with each RN release, so that users can check to see what our "official" support is. ## Supported Components diff --git a/package-mixins.js b/package-mixins.js index 6b18e74..73700d2 100644 --- a/package-mixins.js +++ b/package-mixins.js @@ -41,7 +41,8 @@ module.exports = (NativeCodePush) => { const local = { async install(installMode = NativeCodePush.codePushInstallModeOnNextRestart, minimumBackgroundDuration = 0, updateInstalledCallback) { const localPackage = this; - await NativeCodePush.installUpdate(this, installMode, minimumBackgroundDuration); + const localPackageCopy = Object.assign({}, localPackage); // In dev mode, React Native deep freezes any object queued over the bridge + await NativeCodePush.installUpdate(localPackageCopy, installMode, minimumBackgroundDuration); updateInstalledCallback && updateInstalledCallback(); if (installMode == NativeCodePush.codePushInstallModeImmediate) { RestartManager.restartApp(false);