React Native replace bundle.js - react-native

Is it possible to make a native modules, that can replace main.bundle.js inside application? If UI changes user will not have to update application, application will just pull new js bundle.

Yes. There already are some libraries that do exactly that.
react-native-auto-updater is only the client part that does the update on the device. CodePush on the other hand is a complete solution that also helps you distribute your code.

Related

How to integrate react native component into the native app?

I used to see lots of articles about native modules inside RN apps, but very few about RN inside native project. Let's say we have a project, in which we want to add a single screen fully developed using RN. As far as i know, instagram have something like this. I have read official documentation about this, but it left too many questions. Does anybody know the good step-by-step implementation guide?
Mostly, i'm interested in:
What is the structure. Do i really need to move all the project inside /ios and /android folder, wrapping the whole project? What if the project have separate repositories for both platforms?
Do native developers need to install node environment in order to continue working on the project, installing node_modules and staff?
How much is the influence on the app size?
UPDATE: 07.20.2021
I'm still not able to run an RN screen inside native projects. The docs i told about before doesn't contain actual info, steps are not properly described, and even writing exactly as they told, the project still cannot run and crash as fast as i change activity to RN one.
Here are some points related to the questions that you have which might help you.
No, You don't need to move the whole native code to the /android and /ios directory.
Yes if you are about to open the RN screen from the native app you should have set up the react-native environment properly.
The app size might increase as there is a bridge created with javascript and native code. but you should have a choice to upload the .aab bundle file which helps you to provide the platform-specific builds to the users.

Code-Push with CI/CD and native dependency changes

I am readying an app for release to the app stores and I'm concerned with CI/CD pipeline and Code-Push.
How does this scenario play out:
If a developer makes NPM dependency updates and there is a package updated that has native code changes that the JS relies on, will Code-Push still update the JS bundle on user devices ahead of their device downloading the native code updates?
Just so my question is clear, I'm not trying to OTA update native code - I'm referring to a situation where some package like react-native-device-info has native Java/Swift code and also has JS code that requires some api or event constant from the native code. If you bump the package version for react-native-device-info to a new release and there is changes to both native and JS code, would code-push have any way to know to not update the bundle until the native code/app was updated because the JS bundle has code that depends on the native code?
Or, am I thinking of using the tool Code-Push wrong?
The way codepush works is that it updates the JS bundle of your app. Your requirement is to update a NPM package which has a native change and update only your client side which is not possible.
If you do this you will probably end up with a crash of your app when the JS contacts the native code.
would code-push have any way to know to not update the bundle until the native code/app was updated because the JS bundle has code that depends on the native code?
Simple answer NO
Codepush is targeted on a version number so your new version which hits the stores will have a new version number so no point of updating the bundle of the old version of the app.
If you really want all your users to move to a new version push an alert or some sort of message using codepush asking the user to update.

Is it possible to make a webdav client in React Native without the need of native code?

Basically the title says everything.
I want to create a basic WebDav Client to create, download and delete files from the webdav Server.
But I was unable to find a library which is able to achieve this in React Native.
Any suggestions?
I really don't want to write native code for it...
Another thing is that basic authentication has to be possible.
Thanks,
TK
webdav-fs works on React Native after installing react-native-crypto, stream and shimming Node.js core modules (as described here: https://www.npmjs.com/package/react-native-crypto).
Another step I had to take is to uncomment require("crypto"); in the file shim.js created by rn-nodeify.
webdav seems to work.
But in order to compile, I had to install a few standard node modules that are not in react native : stream-browserify (to replace stream), events, buffer, + I replaced crypto by md5.
not sure, but typescript support for the project may be necessary, too.

code push react native not changed library updates on users App

When I changed a library (like 'react-native-image-crop-picker') version on package.json and distribute it with code push in users app the version not changed.
They see older version of that library in app.
what should I do?
Code Push only works with JS code. It doesn't allow to push native binaries. In your case, you have to update app bundles in stores to update your native dependencies.
The CodePush plugin helps get product improvements in front of your end users instantly, by keeping your JavaScript and images synchronized with updates you release to the CodePush server.
Taken from Code Push docs.

Creating Web Worker in React Native Android app

I am building a React Native android app. In app I want to download and parse huge amount of data from server. Since JavaScript is a single threaded language I don't want to execute this on same React Native JSC context. Is it possible to create a Web Worker inside React Native JSC context and do extensive background jobs?
I have tried to do the same, but it says function not available.
There is a library exactly for that now. Check out https://github.com/devfd/react-native-workers
AFAIK there is no WebWorker polyfill for React Native. You will probably have to write a Native Bridge Module. If you want to avoid that , check out this post where they use requestAnimationFrame to break heavy tasks. https://corbt.com/posts/2015/12/22/breaking-up-heavy-processing-in-react-native.html
Nowadays a library that tries to do something similar with JSI but that is not declared exactly as WebWorker is react-native-multithreading.
For now there is no solution within react-native but news may come in https://github.com/react-native-community/discussions-and-proposals/issues/486