Thanks so much for filing an issue or feature request! Please fill out the following (wherever relevant):
When using wix/react-native-navigation/ , code update works fine until restarting the app. Then it rollbacks to the previous version.
git clone https://github.com/JuneDomingo/movieappsrc/app.ios.js by adding @codePush decorator, the app gets stuck, so I tried #4 below constructor(props) {
super(props);
iconsLoaded.then(() => {
this.startApp();
codePush.sync({
installMode: codePush.InstallMode.IMMEDIATE
});
});
}
(The more info the faster we will be able to address it!)
After spending several hours on this, i finally found a solution/workaround:
import React from "react";
import codePush from "react-native-code-push";
@codePush({
installMode: codePush.InstallMode.ON_NEXT_RESUME,
checkFrequency: codePush.CheckFrequency.ON_APP_RESUME,
})
export class CodePushComponent extends React.Component {
render() {
return null;
}
}
and then just rendered that component in the main screen. This way, I'm using the recommended decorator method. Not sure what kind of sorcery that decorator is doing that I couldn't replicate with sync/notifyAppReady.
Also make sure that in AppDelegate.m you have the right jsCodeLocation = [CodePush bundleURL];. In my case, it looks like this:
#ifdef DEBUG
jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];
#else
jsCodeLocation = [CodePush bundleURL];
#endif
Hi @grigored, got it, thank you for the information, please feel free to reopen if needed. Also let us know if you have any questions or see any issues.
An issue I definitely see is what I mentioned at 3: the codepush HOC doesn't copy static data. I had this problem elsewhere, and am using hoistNonReactStatic to solve it, as described in the react docs.
Thanks for the workaround 馃憤
Worked in my app as well.
@grigored That works for me, except I needed to add 'default' to the export since I had it in a separate file. I would LOVE to see this in the official docs.
Also, to get the @codePush decorator to work, I had to install
https://github.com/skevy/babel-preset-react-native-stage-0
That required modifying .babelrc, calling watchman watch-del-all, and for my dev system (which doesn't use CodePush but still includes the code), restarting my packager (yarn stop; yarn start).
@tmaly1980 The decorator is just syntactic sugar, you don't have to use it. It's equivalent to the code below
class CodePushComponent extends React.Component {
....
}
export default @codepush(options)(CodePushComponent)
I did this way but my codepush get rollback a lot, about 33% got rollback. Does anyone get this problem?
Most helpful comment
After spending several hours on this, i finally found a solution/workaround:
and then just rendered that component in the main screen. This way, I'm using the recommended decorator method. Not sure what kind of sorcery that decorator is doing that I couldn't replicate with sync/notifyAppReady.
Also make sure that in AppDelegate.m you have the right
jsCodeLocation = [CodePush bundleURL];. In my case, it looks like this: