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

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.

Related

React Native Error - TypeError: null is not an object (evaluating '_reactNative.NativeModules.RNShare.FACEBOOK')

I'm working on react native project and I am using expo. I want to add the react-native-share package to my project, however I keep getting this error before I even add any code.
TypeError: null is not an object (evaluating '_reactNative.NativeModules.RNShare.FACEBOOK')
Now I know that expo has it's own version of the share, however you can't specify where a person can share it too, which honestly makes the feature useless. It seems to be clear that the reason I can't use this package is because I am using expo and can't install pod into the project -- due to expo reject it --. So what should I do? Any suggestions on how to work around this?
You can't normally use dependencies with native code using Expo. At least when using the classic build system (you're using it when you run expo start in the terminal to run your project). react-native-share has native code (you can check that by going to the repo and seeing if the library has ios and android folders) and therefore can't be used with "standard" Expo.
If you want to use custom native code in your project, you either need to eject from Expo to the bare workflow or - a newer option - use Expo EAS and custom dev clients. Expo EAS allows you to stay in the managed workflow and still use native modules. You might need to write something called a config plugin for some of those native dependencies you want to use, but looking at the documentation, react-native-share should be working just fine without a config plugin.
So: Either eject to the Expo bare workflow, or use Expo EAS and custom dev clients to use native dependencies with the Expo managed workflow. Do note however that you need at least Expo SDK 41 to use EAS and custom development clients.
To learn more about migrating from the classic build system to EAS, see Expo's guide / documentation.

Is the react-native-video library compatible with an expo project?

I want to implement this library into my expo project, however I'm having difficulties even getting an example up. Is this library compatible?
npm package link: https://www.npmjs.com/package/react-native-video
You can use Custom Development Client to use this library in an Expo Managed Project.
If you don't want to change anything in your project and use it as it is, you can try Expo AV. This provides a Video Component which you can use.

Why is that we cannot install native libraries on Expo? (that requires linking)

I am a newbie and learned react-native expo. I am curious why we can't use any native library with Expo.
For example, if I want to use filesystem on expo I just cant use it, I know expo has it's own file system but I want to use another library but that library requires linking so it is not working in expo. Why is that?
I have tried everything.
This is the library that I want to use ==> https://github.com/itinance/react-native-fs
It requires command : react-native link react-native-fs
How do I do it?
You first have to understand the difference between react-native cli & expo
Please read this documentation to understand the difference
React Native expo uses their own servers to compile your javascript into java and return APK file as a complete APP, and that is the reason you do not need android SDKs or android studio environment on your PC when you are using expo
but when you are using react-native cli you do need the android studio environment such as SDKs, because when you are using cli , it compiles the code using that android studio sdk/environment that you made in your PC that is why you do not need a third party server like expo do.
and thats the reason you get android files right in your react-native project and due to which you can add native modules to it.
However you also have the option to use expo-eject, You can read more about expo-eject in this documentation
Thank You!, Have a great day & welcome to stackoverflow community!.

When to use react-native link?

I understand that react-native link (see post) is an automatic way to install native dependencies. The post above explain how to use the link command but lacking the detail of when to use it. Should it be used after adding a component, every code change or after introducing new module to the app?
Why we use react-native-link??
In this post, I will explain why we use react native link command and when we need to use this command or not?
First, we will understand what is native module??
Native Modules
Native modules are usually distributed as npm packages, apart from the typical javascript files and resources they will contain an Android and ios library project. 
React Native provides an impressive amount of native modules that give you direct access to core platform APIs on both Android and IOS.
For example react-native-maps, react-native-firebase, react-native-socketio etc.
These modules or packages contained both platform (Android and Ios) code.
Now coming on to the react native link
Those libraries which are use native code, in that case you'll have to add these files to your app. For linking those library with react native code need to run react-native-link
Here are the few steps to link your libraries that contain native code
Automatic linking
Step 1
Install a library with native dependencies:
$ npm install --save
Step 2
Link your native dependencies:
$ react-native link
Done! All libraries with native dependencies should be successfully linked to your iOS/Android project.
Where we don't use react-native-link??
Those components which are only written in javascript they are not using any native code (Android and Ios). There is no need to run react-native-link.
For example rn-modal-picker, react-native-check-box etc.
You should check out this other answer: The use of react-native-link command?
You only need to run react-native link NAME_OF_PACKAGE when you install a new package that has a native codebase, or without arguments if you want to do it for multiple of them.

React native to expo migration issue with ReactLocalization module

I have an existing React-native project which I'm trying to move to expo
I have followed the steps described here to do this. I have complete all the steps in the article, yet when I start the project I run into the following error.
From my research what I understood is that, a libReactNativeLocalization.a file is missing from somewhere.
Here is the library I'm using for localization.
What am I doing wrong?
With Expo, you can't react-native-link custom native modules. You write just JavaScript (unless you eject, in which case you're in a roughly similar situation before you tried to convert to Expo).
The way you can do localization with Expo is to use these functions:
https://docs.expo.io/versions/v17.0.0/sdk/util.html#expoutilgetcurrentlocaleasync
There isn't a way to use the native module you link to without ejecting unfortunately.
Good luck!