avatarCkmobile

Summary

The web content provides a comprehensive guide on building a React Native app using Expo CLI, detailing the differences between Expo CLI and React Native CLI, the setup process, and how to run and test the app on a device.

Abstract

The article "How to build a React Native app with Expo" serves as a step-by-step tutorial for developing mobile applications using React Native. It introduces Expo CLI as a simplified tool for newcomers to React Native, abstracting away native code complexities and offering utility features for common tasks. In contrast, React Native CLI provides a more bare-bones approach, requiring additional configuration and library imports for device features. The guide walks through the installation of Node.js and Expo CLI, project initialization, and navigating the file system. It also demonstrates how to start the development server, open the project in Visual Studio Code, and preview the app using Expo's QR code feature on a physical device with the Expo Client app. The article emphasizes the ease of use of Expo for beginners and the flexibility to eject to a more customizable setup if needed.

Opinions

  • Expo CLI is recommended for beginners due to its simplicity and abstraction from native code.
  • React Native CLI is suitable for developers seeking more control and flexibility, as it does not abstract away from the native code.
  • Expo's utility features are acknowledged for making common tasks, such as working with the camera, more straightforward.
  • The article suggests that starting with Expo is beneficial for learning React Native, with the option to eject to ExpoKit for more advanced customizations if required.
  • The use of Expo servers to host the app for live previewing on a device is highlighted as a convenient feature for development and testing.

How to build a React Native app with Expo

A step by step guide to build a mobile app

There are two different ways first we could use to create the React Native app. The Expo CLI or React Native CLI.

The CLI stands for command-line interface. It is tools that we can use in the command line.

Related Course:

Complete React Native articles:

  1. How to build a React Native app with Expo
  2. How to Run the Expo React Native app on the emulator
  3. Expo folder and file structure
  4. Expo React Native View, Text and Style
  5. Expo React Native — using React Hook useState()
  6. How to Use TextInput Component to Change State in React Native?
  7. How to Use Expo React Native List and ScrollView
  8. How and why we use Flatlist in Expo React Native
  9. What is TouchableOpacity in Expo React Native?

What is the difference between these two Expo CLI and React Native CLI?

Expo CLI

Expo abstracts way from the native code and it makes it much simpler to get up and running with react native. Especially if you are new to it. It acts as a wrapper around our app which is going to provide us with a simplified app development workflow.

A lot of utility features and common tasks like working with the camera or other device features , because of the abstraction of Expo, it does offer a little less flexibility because we are limited to what Expo exposes to us, but it does make making these apps much simpler especially if you are a new to react native.

React Native CLI

The react native CLI does not abstract away from the native code. It requires a bit more effort and configuration to get up and running now.

To create a react native app this way is considered to be a pure react native app because it contains no additional utility features or configuration.

It consists only the bare essentials and that means you have to import all the libraries to achieve different things, like working with the camera.

Using expo is kind of like a beginner series to react native.

At some point in the future if you ever wanted to switch from Expo to have the bare-bones approach, you can do that by simply ejecting the project at any point.

Workflow

The first thing we need to do right here is download node.js .

Why we installed node is to get the NPM node package manager so that we can install other things

We copy it and paste it inside a terminal or command prompt and then press ENTER.

npm install -g expo-cli

What this does is to install Expo CLI globally on your computer.

Next, we are going to create our first react native project so you can see down here now

Create a new project

Go to the terminal now to create a new project

We say Expo in it for initialize and then the name of your project

expo init my-project

We need to navigate to the directory in your terminal where you want to create this project.

To navigate around just use CD for change directory and then the name of the directory. For example if you want to go to a folder inside the apps directory called “reactnative project”, you need to say

cd reactnative\ project

It would take you into that folder once you press ENTER

Go into the folder by using CD

and if you want to go up a level you could say

cd ..

This is where I want to create the project named “my-project” so we need to type following command and press ENTER

expo init my-project

It is going to give you a few different options right here. We can use

a blank workflow in the manage workflow or we can use tabs or minimal etc.

expo init my-project

We are going to go use a blank project in a managed workflow and it is going to create a new project for us.

installing JavaScript dependencies

Once it’s done that you can see to get started you can type “cd my project” to

go into that directory and then “npm start”

We are going to say “cd my-project” and then before we type “npm start”, we are going to open the visual studio code in this directory from the terminal we can type “code .” in current directory and press ENTER.

Visual Studio Code

We got all of these different folders and files down and we going to open up the terminal in Visual Studio Code.

Next thing we are gonna do is type “npm start” and press ENTER.

It is going to run expo start under the hood and it will open up a new tab in the browser.

We could use the QR code at the bottom left to test our app directly on our device.

What we need to do is to install an app on your phone called Expo clients. Once we have done that we can just scan this QR code with the camera of the phone.

Expo client app

It should allow you to open up your native app inside the Expo Client, so that you can preview it.

Scan the QRcode with camera in iPhone/ Expo Client in Android

Once this app is installed you can then open up your camera on the iPhone or a QR code reader of Expo Client on Android, scan that QR code.

Then it is going to open up that project inside expo client, so basically what is happening behind the scenes is expo servers are hosting our app and the Expo Client is connecting to those servers so we can preview the app in our own device.

Subscribe Youtube:

Follow Us:

React Native
Reactjs
Android App Development
iOS App Development
JavaScript
Recommended from ReadMedium