Why does async bridge means no awareness between Javascript and Native sides? - react-native

I watched this video about React Native new architecture (made by a React Native core maintainer) and I have a few questions
https://www.youtube.com/watch?v=sdQHzjV90ow
Why does async/batching mean no awareness between JS and native side?
It seems like RN use JavascriptCore because iOS enforces that. If so then does it mean even if JSI allows us to easily swap engine, we can't really do it on iOS? Also is Hermes a customized version of JSC because since RN 0.60.4 we can use it instead of JSC?
Why is sync communication between JS and Native is better? Isn't sync more bottleneck prone?

Related

Is Viro -React app be independent appication?

I have a question: I'm going to develop an AR app with viro for react native.
Will I be able to publish the project without the Viro Media app that they're suggesting for development?
Of course, you can create an independent Viro app and build it either from Android Studio or by exploiting the React Native CLI, as it is described here.
Remember to use an ARCore supported device to access native modules and the AR functionalities.

Can I use flutter in my react native app?

So I have a react native app and was hoping if I could use flutter for some components.
We are using redux for state management and was curious if we could use the same redux store for flutter components.
And for persistence we are using realm, was curious if flutter supports realm.
No you can't use flutter component into react native because both are written in different technology language stack.
Flutter is an open-source mobile application framework that works on
a completely different programming language called Dart, While React
Native lets you build mobile apps using only JavaScript.
Dart is based on c/c++, java and supports things like abstraction,
encapsulation, inheritance, and polymorphism. Flutter team picked
Dart because it matched the way they were building user interfaces,
With Dart bridge, the application size is bigger, but it works much
faster. Unlike React Native with Javascript bridge.
Second Redux is an application architecture, made originally for
JavaScript. Redux provide library for both but we can't use same
redux state for react native and flutter. Redux are written
different for both platform with same functionality and
working(state management)
Realm is also a third party plugin which is available for both
platform but we can't share code between both platform.

How can i incorporate Expo components in a non-expo React Native app?

I'd like to use Expo's barcode scanner component in a non-expo app that i've already mostly built:
https://docs.expo.io/versions/latest/sdk/bar-code-scanner.html
Is it reasonable to do this? Or is it more reasonable to create a new Expo app then migrate my existing codebase into the new expo app?
My existing app was created using react-ignite, not sure if that is relevant or does not make a difference.
Generally speaking, integrating Expo components with native dependencies (such as the camera) into a non-Expo app is possible, but is a bit tricky, as you'd have to lift the source code from the Expo codebase into your application.
The JavaScript code for these modules exists in the expo/expo-sdk module, and are quite straightforward:
CameraBasedBarCodeScanner
Camera
However, the native module that's required to make the Camera work are embedded within the expo/expo client application, and depends on other parts of the Expo codebase.
Instead, I recommend you use the react-native-camera component, which supports barcode scanning out of the box, and is easier to integrate into a plan React Native application.

Why do react-native packages use native SDKs and not JS/web versions?

Purely informational question, not really a problem but:
I remember following the instructions and seeing that there were some steps to get the react-native-fbsdk working. These steps involved messing with my android build.gradle and adding the iOS SDK and the info.plist and whatnot. That aside, why doesn't Facebook utilize the javascript SDK? Is it not possible? If so, why is it not possible for Facebook to do this? If it is possible, why did they opt to utilize the both the android and iOS SDK?
One value prop of React Native is that it's not just an HTML 5 website embedded in a native wrapper. It literally uses the native APIs/components, and the same goes for SDKs. Technically, a pure JS SDK could be optimized for a browser experience, rely on window or document, and while the functionality might be able to be executed natively, the polyfills provided in RN might not be enough to cover the implementation. The way it makes API calls are probably different too. The views are different too (no DOM in RN), so that would apply for any SDK views (button?).
I just finished converting an iOS SDK to a React Native package and I feel that the implementation will be more inline with how the original iOS SDK was designed, since it's using those methods under the covers instead of pure JS. JS is just invoking the native methods, not taking over the methods.
Just my $0.02...

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