React Training
  • React JS Library
  • Roadmap
  • Training OutLine
  • React js basics
    • Understanding React JS
    • React JS a framework?
    • Setting Up React
    • Say Hello to React
    • Everything is a Component
    • Create-react-app
  • React Building Blocks
    • JSX and Babel
    • One Way Data Flow
    • Virtual DOM
    • V of MVC
    • React Terminology
    • React Tooling
  • Day 01
    • Day 01 OutLine
    • All About JSX
    • React Tools/ npm & webpack
    • Introduction of Webpack
    • Hello world using webpack
      • Webpack Setting up with React
    • NPM Scripts | Package JSON
      • Package.json file
    • React JS Principles
      • One Way Data Flow
      • V of MVC
      • Virtual DOM
    • Create React App - Part-1
    • Create React App - Part-2
  • Day 02
    • Quick Recap
      • Quiz
    • State & Props
      • State & Props in Depth
      • State Vs Props | Compare
    • React LifeCycle Methods
      • React LifeCycle Methods for V-0.16 x
    • Constructor | Lifecycle
    • Write Flicker App | First App
  • Day 03
    • Quick Recap
    • Life Cycle Flow
      • Birth and Mounting
      • Initlization and Construction
      • Pre Mounting
      • Render Method
      • componentDidMount
    • Type of React Components
      • Examples- Quick Compare
      • Class and Functional components
      • Functional Components
    • YouTube application
      • Component Design
    • All in One LifeCycle
  • Assignment
    • React App development
  • Day 04
    • Quick Recap on Lifecycle
    • Lifecycle deprecated/New Methods
      • New Lifecycle Methods
    • Lets Build App Netflix | Mock
  • Assignment
    • Github battle App | Assignment
  • Day 05
    • Quick Recap : Hooks
    • ES6 Features | Hands-on
      • ES6 Code Examples
    • Next Stop - React Router | SPA
      • Code examples | Router
      • React Router Building Blocks
      • Application using react-router-dom
  • Day 06
    • Router V4 | Quick Recap
    • ES2015 | 16 Quick Recap
    • LifeCycle Methods -Part-1
    • LifeCycle Methods -Part-2
  • Day 07
    • Quick Recap | New Lifecycle
    • Quick Recap | React Routing
    • Context API | React JS
      • component with context APIs
      • Context API | examples
    • App using Hooks/Context APIs
  • Assignment
    • Assignments
  • State Management Day-08
    • Quick Recap
    • Managing React State
      • What is Redux
      • Understanding Redux
      • Hello World "Redux"
  • React Redux Day - 09
    • Redux State Manager
    • Redux Redux Development
    • Simple Application | Redux
  • Redux Live Application Day -10
    • Redux with existing Application
      • Redux with React App
      • Lets Build More Apps
      • Should I use Redux from Dan
    • Quick Look at JS in React
    • Learn By Reading
  • miscellaneous Items - Day 11
    • Hooks useReducer
    • Hooks useContext
    • Hooks useRef
    • Hooks useEffect
    • Hooks useState
    • Lazy Loading and code splitting
    • Styling React Component
  • React Next Step - Day 12
    • Topics
    • Jest and Enjyme Testing
    • Examples: Testing
  • React Native
    • What is React Native
    • Setting up Environment
      • Linux Systems
    • React Native Hello World App
    • React Native Architecture
    • React Native Vs Native
    • Expo Cli or React Native CLI
  • React Native core Fundamental
    • React Native "Hello World"
    • Course OutLine
    • Getting started with Expo App
    • Layout with Flexbox
    • Working with Styles and Events
    • Manging Component State and Props
    • Build Simple Task List Application
  • What to Debug & How to Debug
    • Debug React Native Application
Powered by GitBook
On this page
  • Setup Environment
  • Creating and Launching an App
  • Run on iOS Simulator
  • Run on iPhone

Was this helpful?

  1. React Native

Setting up Environment

PreviousWhat is React NativeNextLinux Systems

Last updated 4 years ago

Was this helpful?

Setup Environment

To start setup the environment, you will need to first to first install npm. This can be done by installing . You can follow installation from the site so I won’t cover detail on that step. Once that is done, we can use npm to install all the necessary tools. There are few ways to get started.

1. Setup using react-native-cli (older approach)

This approach allows you build directly to the native apps with fewer layers. But I find this approach of building a little slow. I recommend the approach 2 below instead. So for this approach you run:

npm install -g react-native-cli

To create a project, run (replace the “<project_name>” with the name of your project:

react-native init <project_name>

You may run into sisueOther notes: rebuild issue: rm -rf node_modules && npm install

2. Setup using Expo (current approach from react-native as of Oct 2018)

This is a more recent approach from react-native site. I recommended this approach than the previous one. It is more responsive in building and testing. This uses an additional layer call (previously known as Exponent). It is a tool chain build around react native to provide more flexibility to run and test your app.

Run:

npm i -g expo-cli npm i -g create-react-native-app

To create a startup project run:

create-react-native-app <project_name>

Creating and Launching an App

When running create-react-ative-app, you will prompted by to choose a temple with two options (blank or with sample navigation). I choose blank.

$ create-react-native-app MyApp? Choose a template: blank[08:14:42] Extracting project files...
[08:14:54] Customizing project...Your project is ready at /projects/react-native/MyAppTo get started, you can type:cd MyAppexpo start

The next to run this, just type in the commands suggested above. You can also use “yarn start” instead of “expo start”.

$ expo start[08:18:48] Starting project at /projects/react-native/MyApp[08:18:56] Starting Metro Bundler on port 19001.[08:18:56] Metro Bundler ready.[08:18:57] Expo DevTools is running at http://localhost:19002[08:18:57] Opening DevTools in the browser... (press shift-d to disable)exp://192.168.1.120:19000
...
  To run the app with live reloading, choose one of:• Scan the QR code above with the Expo app (Android) or the Camera app (iOS).• Press a for Android emulator, or i for iOS simulator.• Press e to send a link to your phone with email/SMS.• Press s to sign in and enable more options.Press ? to show a list of all available commands.Logs for your project will appear below. Press Ctrl+C to exit.

A web browser window will pop up. I will leave the command prompt as is and interact more in the web browser instead. You only need to come back to the command prompt if you want to stop the process by pressing Ctrl+C.

In the browser, you will see this:

Run on iOS Simulator

Now you can click on Run iOS simulator to start the simulator. The simulator will start up and run Expo and download the Javascript bundle. You will see this:iOS simulator screenshot

Now you should see this. Now you are set to go.

Run on iPhone

To run on the iPhone device, you have a few simple options. But first install and run Expo on your iPhone. You will need to register a free account with Expo. Notice that you iPhone must connect to the wifi as your computer running the expo when you select “CONNECTION” as LAN.

  • Start Safari browser and type in expo address from the browser screenshot above: exp://192.168.1.120:19000

  • You browser will prompt to use Expo, choose that and now your Expo will start to launch your app.

Image for post
Image for post
Image for post
node.js
Expo