Is glibc used in react native? - react-native

I am wondering if any of you know, whether or not react-native uses glibc library as their dependency. I've searched everywhere, and the only thing I've found was the link. It says:
NOTE(agallagher): The platform really should be responsible for providing
this type of provided dependency. As it is now, we need to setup dummy
rules to model glibc's libraries.
Does anyone know anything else?

React Native does depend on some components of glibc (like pthread which is the first mentioned precompiled library in the link you mentioned) but those same components are offered by Bionic, Android's own C library.
Since Bionic is precompiled and bundled with the OS, React Native leverages that implementation instead of using glibc, which explains the note:
The platform really should be responsible for providing this type of provided dependency.
On iOS, pthread and other C libraries needed by React Native are already available through the iOS SDK.

Related

Can I use new React Native architecture with libraries which doesn't support it

This year React Native team introduced new architecture https://reactnative.dev/blog/2022/03/15/an-update-on-the-new-architecture-rollout. This functionality is still under the flag but for me is not clear, can I use all libraries which working with old bridge with this new architecture?
I haven't found answer in the official documentation. Only thig I found is a list of libraries which support new architecture. https://github.com/reactwg/react-native-new-architecture/discussions/6
It depends on what type of a library it is. Library maintainers can add support for both architectures.
You can find a compatibility table in this readme.

react native how to know if a repo I am importing is a native module

my question might be a little bit silly or ambiguous since I am fairly new to react native.
I'm trying to use the following repository for my react-native project https://github.com/smekalka/react-native-universal-pedometer. I have noticed that the repo is implemented in .java with platform folder unlike the regular .js or .ts files I used to see. Is this repository considered native module as react native doc describe?
Or in general how I can tell the whatever lib I am using is a native module.
The project is previously tested are under the support of expo-cli. I experienced the error null is not n object while using this repo. If so, I am probably going to eject the expo-cli and rewrite my code so I can use and even create own native-module for full control, some core implementations that written in other languages or expo-cli does not support.
Yes, the android and ios directories in the repository contain the 'native' code used to implement the platform-specific hooks that the Javascript will be able to pick up. Expo is not able to use these native modules or native code so your assumption is correct; you will need to eject your app in order to use this module.
If your app is below version 0.60 of React Native, after installing the module you will need to run react-native link react-native-universal-pedometer to link the native code to the Javascript runtime. If you're above 0.60, it will link automatically when installed.

Is it necessary to link every react-native library after installation?

There are number of react-native libraries which makes developer job easy and it's a common practice to link library after it's installation. But for some libraries linking is not done(As those library developers are not asking to do so). For example react-native-swipeable for which linking was not asked on their git hub page. Another package native-base for which linking is mandatory but there was an error when i tired to do so, But still package is working fine.
Can somebody let me know the consequences that we face if any package is not linked?
Some libraries make use of native code, so linking should add to your project all native dependecies. For instance, react-native-swipeable might be a pure JS library and no linking is used. Which means no native code is used by react-native-swipeable.
For more information on linking please refer to: https://facebook.github.io/react-native/docs/linking#docsNav

Can you add libraries with native dependencies to an Expo react native project?

Can you use libraries like https://github.com/tolu360/react-native-google-places in an Expo project? I assume any npm library is ok to add, but what about libraries like this google places picker that requires post install steps to link the native projects. Are they supported with Expo?
Regular Expo projects are written only in JavaScript and don't support npm packages that contain Objective-C or Java. However, Expo provides an advanced SDK called ExpoKit for when you absolutely need to use custom native code. From the Expo docs:
Normally, Expo apps are written in pure JS and never “drop down”
to the native iOS or Android layer. This is core to the Expo
philosophy and it’s part of what makes Expo fast and powerful to
use.
However, there are some cases where advanced developers need native
capabilities outside of what Expo offers out-of-the-box. The most
common situation is when a project requires a specific Native Module
which is not supported by React Native Core or the Expo SDK.
You could "detach" your Expo project to create Xcode and Android Studio projects that contain ExpoKit. Then you would add custom Objective-C or Java the same way as with any other Xcode or Android Studio project.
However, the Expo docs also warn about some of the downsides of writing custom native code; many features often can be implemented well in JS, allowing you to retain all of the benefits of a standard Expo project.
Warning: We discourage most of our developers from taking this route,
as we believe almost everything you need to do is better accomplished
in a cross-platform way with JS.
Writing in JS enables you to best take advantage of over-the-air code
deployment and benefit from ongoing updates and support from Expo.
You should only do this if you have a particular demand from native
code which Expo won’t do a good job supporting, such as (for
example) specialized CPU-intensive video processing that must happen
locally on the device.

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...