Still cannot use `react-native link` after ejecting a Create React Native App - react-native

I started with a create-react-native app. Then, I wanted to add a dependency. So, I ran react-native link:
`react-native link` can not be used in Create React Native App projects. If you need to include a library that relies on custom native code, you might have to eject first. See https://github.com/react-community/create-react-native-app/blob/master/EJECTING.md for more information.
So, I ran npm run eject and it successfully ejected. There are many changes to the package.json and some scripts have been added.
But, if I now run react-native link, I still get the same error!! How can I successfully run this command? How does it determine that I'm still using create-react-native?
I'm guessing there's some flag somewhere that still says it's using create-react-native, but I don't know where it is. Any help is appreciated.

react-native link
only works when you have added any new package eg:- npm i react-native-vector-icons. then you need to import package name to various class manually but if you dont want to do it you can directly run the command
react-native link react-native-vector-icons OR react-native link
this will automatically add import the package to your ios and android files.
Try these steps it will work.

Related

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.

is it necessary to rebuild react-native project after linking

I would like to know if it's necessary to rebuild react native project after installing and linking libraries that includes native codes.
Yes, as react-native-link updates some native files that are under the ios/android folder, that won't be checked during a reload/hot-reload/live-reload. All those files aren't checked in your jsBundle and are compiled during a run-android or run-ios.
Of course, if you added a new dependecy to the project and linked it, and you haven't used it anywhere in your code yet, you don't need it. If you are using that dependecy, your project instance will, most likely, die.
if your react native version is below 0.60 then you have to run react-native-link after you install any react-native module. However after react-native version 0.60 and above, this is done automatically using the new "autolinking" feature added.
Read the changelog here:
https://facebook.github.io/react-native/blog/2019/07/03/version-60
However you still need to rebuild your project after you install a native module but you dont need to run the react-native-link command anymore after installing every library after react-native#0.60 and above. Just type react-native run-android

React Native not installing properly

I am familiar with React Native. I got a new macbook and I am trying to create a new file. However, when I run create-react-native-app [name of app] I am greeted with:
This command requires Expo CLI.
Do you want to install it globally [Y/n]?
When I pressed Y it created the file, however, in a complete file layout. It looked so odd and there were some files missing too.
Normally, when I run create-react-native-app it created the file without asking anything about expo. I am pretty confused. I'm pretty sure I have done wrong somewhere. Where and how I can get the traditional installation process back?
I also know that expo helps with testing. Since may I have been using npm start and npm run ios to test my apps on device and xcode simulation.
https://facebook.github.io/react-native/docs/getting-started I followed this.
New version out now and create react native app has been merged with expo CLI.
To avoid any bug use new version to create react apps, follow the command bellow which is also in the link given in your question.
expo init AwesomeProject
After installation you will be guided to start project with expo start.
cd AwesomeProject
expo start

How to recompile react native app without rebundling assets

I am working on a react native app, but on its native side.
If I run react-native run-android or run-ios it will first build
the native packages, to then start and complete the packager (at least for production). This process takes a long time. Is there a way to tell the script to use the latest built version of the assets, and just recompule the native binaries?
EDIT: I found out that you can add org.gradle.configureondemand=true to your gradle.properties, in order to skip bundleJsAndAssets. However, I can't find how to add the assets manually later.
you can install Webstorm IDE and then install React Native Console plugins for this.
Finally, link to the your project.
It's likely that you can see what you want

Twilio import error: Module cannot be null

I've done npm install --save react-native-twilio and react-native-link in my EXPO react-native project. the code compiles without error. But when I add this line of code:
const Twilio = require('react-native-twilio');
in my file, it reports an error says Module can not be null.
I think it is because I didnt link my twilio library to the project right, but I dont know how to fix it, can someone give me some help?
It looks like react-native-twilio has native dependencies and with EXPO, its not possible to include custom native modules. The only way is for you to eject your app to create native builds.
[Official docs for ejecting] (https://github.com/react-community/create-react-native-app/blob/master/react-native-scripts/template/README.md#ejecting-from-create-react-native-app)