Creating new project ReactNative - react-native

On the official website we can read how to create new project:
create-react-native-app AwesomeProject
but on tutorials I always see:
react-native init AwesomeProject
What is the correct? What is the difference between them

One uses Expo and the other does not. With create-react-native-app you use Expo and native code is totally transparent to you.
With the typical react-native init, you get all the code and you can modify native code if you want (or write custom native modules).
You can find everything documented here: https://facebook.github.io/react-native/docs/getting-started.html
First tab, Quick start is about create-react-native-app, second tab Building Projects with Native Code is about react-native init.
Probably in most tutorials you find the react-native init option because that option is there from the very beginning while create-react-native-app is newer new utility.
Recommendation:
If you know you will need to modify native code, use react-native init. If not, you can go with create-react-native-app
Even if you go with create-react-native-app, if at some point your needs change, you can eject

Referencing EvanBacon's answer, react native init creates a purely react native app, whereas Facebook's create-react-native-app makes a project "bootstrapped with expo."

Related

Using React-Native Cli, how to use constants etc. other expo dependent things?

So due to some issues, we starteed project without expo but now every other tutorial shows expo, it uses constants or icons from expo, how to use them?
you can install follow these instructions: https://docs.expo.io/bare/hello-world/
alternatively, init your project with expo init and choose a "bare" template - this is the same as a project created with react-native CLI but with expo modules set up.

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

Upgrading a project from react-native to create-react-native-app?

I'm trying to use create-react-native-app as per the documentation with an example project that was built using instructions for react-native.
In terms of translating from one to the other what are the steps involved?
Edit: So i can run the app using npm start, with the expo.io QR code appearing as an option etc?
Create-react-native-app create a new project with Expo, you can eject it to turn it into a react-native project (android/ios folders with native code + src folder with javascript code).
You'll need an Xcode/Android Studio environment to run a react-native app built without Expo.
You can't use Expo to run a React-Native app with custom native code.
Related links : Ejecting from Create React Native App
What is the difference between Expo and React Native?

How to use expo kit in react native init?

I have used create react native app tool to create initial setup of the my app. With CRNA i used Expokit also. After ejecting CRNA into react-native init setup i couldn't use expo camera features. I'm getting below error while launching app in simulator ("undefined is not an object(evaluating 'ExponentConstants.linkingUri)"). How resolve and use expokit after the eject the application?
Now you can use react-native-unimodules
If you create a React Native project through react-native init or with
another tool like ignite-cli, then you’ll need to add the
react-native-unimodules package to your project and configure it
first: follow the instructions in the README.
See detail at expo blog.
After you eject from create-react-native-app you need to use Git or another version control tool to go back. You can create a new project with create-react-native-app, copy over your JS code, make sure it works, and then eject and this time choose the ExpoKit choice.
It's not possible yet, according with this answer in the Expo Forumn: https://forums.expo.io/t/react-native-init-expo-sdk/1903/2

ReactNative Eject Explained

I literally started reading about ReactNative an hour ago and am reading this git readme https://github.com/react-community/create-react-native-app/blob/master/react-native-scripts/template/README.md
Next I googled about it and found this link which seem to be explaining it but not to me novice in web, react, or react-native
https://github.com/react-community/create-react-native-app/blob/master/EJECTING.md
Can someone explain to me as if I am 2 years old what is the meaning of eject? I keep hearing term "ejected project" but I cannot wrap my head around it.
Summary
If you created an app using create-react-native-app MyApp, ejecting your app gets your app to be the same as if you created your project using react-native init MyApp
aka
create-react-native-app MyApp > make changes to app > eject app
is roughly equivalent to
react-native init MyApp > make changes to app
More Details
What's the difference between create-react-native-app MyApp and react-native init MyApp?
Quick start vs. Full scale development
The philosophy behind create-react-native-app is:
Minimal "Time to Hello World": Create React Native App should reduce the setup time it takes to try building a mobile app to the absolute minimum, ideally on par with React web development (especially as seen with Create React App).
Develop on Your Device: It should be easy to develop on a physical device when you want to test how your app feels and responds to inputs.
One Build Tool: If you just want to get started with React Native, you shouldn't need to install Xcode, Android Studio, NDKs, or mess with environment variables.
No Lock-In: You can always "eject" to your own build setup if you need to write custom native code or modify how your app is built.
Essentially, create-react-native-app lets you get up and running quickly without having to a do a lot of (or any) configuration. In order to do this, it hides a lot of details from you.
If you want to create a serious app, you need to set up a real development environment. You can do this from scratch by running react-native init <project-name>. If you started with a react native project using create-react-native-app, you can get to this same place by "ejecting" your app
More details from the official documentation about getting started with React Native can be found here.
My understanding is that when you run the "create-react-native-app" (or "expo init" now) you are basically adding the Expo library on top of React Native.
I think the main reason for using Expo is to get your app up and running quickly. I think the main reason to eject is that eventually you might need to do more complicated customization with native code and need more control, etc. Here is a better explanation of Expo vs React Native CLI to bootstrap your app:
https://levelup.gitconnected.com/expo-vs-react-native-cli-a-guide-to-bootstrapping-new-react-native-apps-6f0fcafee58f
When you eject you are returning to the same state as if you did not use Expo to setup your app (native ios/android projects will be generated, etc.)
Here are a few other links that helped me understand:
http://www.reactnativeexpress.com/environment
https://docs.expo.io/versions/latest/expokit/eject/