How to get JavaScript changes to automatically load using the dev server when restarting app on Android


(Andrew Forster) #1

If I make changes to the JavaScript while the application is running and I have the live reload enabled everything works fine. However, if I make changes to the JavaScript when the application is not running the changes are not automatically realized when I start the application. I must double tap to force a reload and re-bundle. Therefore, every time I run the application I must also double tap to reload.

This only occurs if a bundle was already cached by a previous application run. I do understand the React Native code and that this happens because of the ‚ÄúhasUpToDateJSBundleInCache‚ÄĚ check.

A similar problem happens when I switch between various branches of the same application. After switching to another branch running the application is going to load the cached bundle from the previous branch. I must again reload.

My main question is how do others deal with these scenarios? Is there something we can do to enjoy the benefits of a cached bundle, but also ensure that it gets regenerated when the JavaScript has actually changed?

For reference, the iOS implementation does not have the same issues. Restarting a React iOS application after JavaScript changes causes a re-bundle.

Thanks
Andrew