React Native not installing properly - react-native

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

Related

React Native: Is it possible to use Expo just for development?

I am new to Expo but so far it seems super neat not having to open up Android Studio / Xcode to run my app locally. Not having to touch that stuff makes it so much more convenient to develop.
However, I want to incorporate in app purchases (subscriptions) in my app and from the research I've done so far it doesn't seem like Expo's solution (https://docs.expo.io/versions/latest/sdk/in-app-purchases/) is very developed.
I found this npm package for in app purchases and it looks promising: https://github.com/dooboolab/react-native-iap. However it is not supported by Expo, and I don't feel like it's worth giving up all the benefits of Expo just for this one feature.
I noticed a comment in the issues here that was quite intriguing: https://github.com/dooboolab/react-native-iap/issues/174#issuecomment-393704277
This person suggests that I can continue using the master branch with Expo, and then following these steps to eject and deploy when time is ready. I've never done this, but I'm wondering if this could work:
On master:
1) Run npm install --save react-native-iap but DON'T run react-native link react-native-iap.
2) Wrap my In App Purchase module with this code. This way your code won't crash when calling IAP methods
import { NativeModules } from 'react-native';
const { RNIapModule } = NativeModules;
function hasIAP() {
return !!NativeModules.RNIapModule;
}
3) Continue developing using Expo, and just skipping the IAP stuff if !hasIAP()
On separate branch used for final QA / deployment:
1) Create a new branch called detached
2) Run expo eject
3) Run react-native link react-native-iap and all the other Manual Installation steps listed here: https://github.com/dooboolab/react-native-iap#manual-installation
4) QA everything
5) Deploy
Does anyone have experience doing this hybrid "expo for development, no expo for production" approach?
If you eject and use the Expo, you can use it like a default React-native project. The Android folder and the iOS folder are created and you will enter the appropriate package name before you create them. The modules you have installed and the modules in Expo are added to the package list when you eject the Expo. Check MainApplication.java for Android or Info.list files for iOS. There are some things that do not apply to App.json settings that were responsible for setting up after you ejected the Expo. It can be set up by referring to the official document.
Once the Expo has been ejected, the React-native link command is performed brilliantly.
ejecting the Expo does not change or disappear from the module usage

Expo React-Native App doesn't work when run as a standalone APK

My Expo-based React Native App works without a problem when run in the Expo tool but gave the following errors when built as an APK to be installed and run standalone.
A series of white screens keep flipping before the blue screen comes up.
Here are my App.JSON and Package.JSON files
Package.json
App.json
And here are the screen capturing the error message.
Actually there are two ways to create a React Native application
create-react-native-app (CRNA)
react-native init
As you stated in comment section, You created your project using CRNA
CRNA will gave you some form of solid project structure, which is really useful for beginners to get started with react native, you code the app with pure javascript and the app will work inside Expo.
Now if you want to take build and run as a standalone apk for android,
There are two methods
You can run command: exp publish:android
You can eject your app from expo
Dont use exp publish for standalone apks,
You can use second method:
To eject your app:
First if you dont use any expo apis inside your apps, it is very easy to eject and build as a stand alone apk.
just do yarn eject
This will gave you some instructions and follow that.
After that your CRNA project structure will be converted into react-native init project structure, now you will be able to see "Android" and "iOS" folders inside your application
To take build Run: connect your phone with USB debugging ON and react-native run android.
That's all.
Solved my own problem. The 'eth-lightwallet' library works perfectly within the Expo development tool but when I build into an APK, it just made the white screen turns up with no meaningful error messages.
The solution is to replace it with a pure web3js implementation.
This may be useful if you are developing a mobile app for Ethereum.

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

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.

Converting project to react native init

Firstly I created my project with create-react-native-app and I'm developing my app with npm start and I have expo installed on my emulator. How can I convert these project into react native init, I don't want to use expo anymore...I don't neeed any api-es from them...
Thank you
The best resource for this is in the create-react-native-app repository. Try having a look here to get started.
The short answer is to use npm run eject
If you have experience generating signed APKs for Android and code signing with iOS then you shouldn't run into too much trouble.
If you don't, then take the time to go through the Android docs and also this guide should help you get up on running on iOS as well.
Good luck!
Instead of creating your project using the command create-react-native-app, you may create a react native project by following "Building Projects with Native Code" of the getting start guide: https://facebook.github.io/react-native/docs/getting-started.html.
Here you will find out how to:
1. Set up the environment.
2. Installation of phone emulator.
3. Connection of your phone via USB for testing.
4. Create a project using the react-native init command.

cannot create iOS folder on my react native app

I am asking this question for the third time and I don't get it why no one even tries to help on this, is this question not well explained? If you can ask for more information I can give!
I am having trouble created iOS folder inside my react native app(detached) as when I created the app I created it from windows machine and iOS folder didn't come when I wrote: exp detach
Now that I have got a macOS, how can I get to create iOS folder so I can use that to build from xCode. I tried react-native upgrade, this is telling me that I have some version conflicts, so I don't want to upgrade it actually, I just want to have iOS folder on my react native.
What would be the best solution in here?
Interestingly I tried exp detach over my detached app and it created iOS, it's working! hopefully this will help anyone!
Please follow the below steps:
Step I: Ensure below installable are installed
Java Sdk Android Studio
Xcode (in case of OSX)
HomeBrew (in case of OSX to install node)
Node/NPM (Node runs Javascript outside the browser. NPM is used for installing and managing Dependencies. Node and NPM come
together)
Those are some essential installs that you will need in your Project
**Step II: **
For windows/OSX you need to run the following commands in your command prompt/command line:
This is the important part for running a react native project:
**Step II: **
npm install -g react-native-cli
Then you can use this cli to start a new project like this:
**Step III: **
react-native init
Hope this helped you, please vote..