How to link native library to react native application and what is the folder structure? - react-native

I am trying to build simple app to creative native library and link with react native app.
I am facing issue like
Error : Unable to resolve module react-native-fingerprint from App.js: react-native-fingerprint could not be found within the project.
Note : 'react-native-fingerprint' which is been created and want to link with app.

I guess you're using react-native-fingerprint-scanner. Since library you mentioned doesn't exist.
In case if you using this library react-native-fingerprint-scanner.
Installation
npm install react-native-fingerprint-scanner --save
or
yarn add react-native-fingerprint-scanner
Link to Native Platforms
react-native link react-native-fingerprint-scanner
Even after this it is not working. Following this guide

Related

Using highcarts in react native and getting the error

I have installed npm install #highcharts/highcharts-react-native in my react native project and i also added the hcscript in metro.config.js file.
Iam getting the error of
Failed to fetch scripts or layout. The method or property expo-file-system.readDirectoryAsync is not available on android, are you sure you've linked all the native dependencies properly?
if you wanted to use this package: #highcharts/highcharts-react-native you should first install react-native-unimodules which is a set of native dependencies used at the core of #highcharts/highcharts-react-native as
they built the package on top of expo not bare react native.
it is going to require you to make heavy edits in the native ios and android files such as appDelegate.m in ios and more alike files.
However, you should notice this package is deprecated as per the official page, and there is no reliable alternative!

Sendbird SDK requires fs package in react native

When I install the sendbird SDK into a expo managed react native project I get the following error:
The package at "node_modules/sendbird/SendBird.min.js" attempted to import the Node standard library module "fs". It failed because React Native does not include the Node standard library. Read more at https://docs.expo.io/versions/latest/introduction/faq/#can-i-use-nodejs-packages-with-expo
However fs is a node package which isn't the environment run by react native. I've looked through the Sendbird examples, and have used this very same SDK in other apps. What am I doing wrong with this one?
SendBird here! Our apologies, but there is a known issue in JavaScript version 3.0.119 that is causing it. This will be fixed in the next version, coming very soon! In the meantime, please build with version 3.0.118 as needed.
If you are using npm, you can run this command:
npm install --save sendbird#3.0.118

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.

React Native Video

i'm trying to use 'react-native-video' in my application, i have used the following lines to get it:
npm install --save react-native-video
react-native link react-native-video (since my react native version is 0.59)
after doing so and using "Video" component from 'react-native-vide' i got an error like below:
what is the problem? what can i do? any ideas?
You did not link the library properly.
After having installed the library through npm i --save react-native-video, you'll need to run react-native link react-native-video in order to link it. This may or may not work - if it does not, you'll need to link manually according to the installation instructions of the library.
You might be using CocoaPods in which case you'll need to run these commands as well: cd ios && pod install
If you receive an error, you're most likely not using CocoaPods and this is the wrong approach.
Please note that you'll need to reinstall the app on the phone / simulator afterwards since you've changed the native dependencies. You'll also need to do this if you're using (ejected) Expo or anything alike. If you're using Expo with the managed workflow (= not ejected) you're not able to use libraries that depend on native linking.

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.