Starting with React-Native(iOS/Android)

Hey folks, React-Native is happening Framework for Mobility in recent times due to it’s tremendous success which was developed by Facebook. Overall it’s a new way of developing native iOS and Android applications, primarily using a single codebase on React framework for web. The idea is to write the core application in Javascript and React-Native will compile native iOS and Android applications. Companies like FaceBook, Instagram, Netflix, Airbnb use React-Native.

Major Advantages of React-Native

  • Building native mobile apps using JavaScript and React.
  • No need to recompile every-time to check the changes.
  • Use native code when you need.
  • Maximum code reuse & cost saving.
  • Strong performance for mobile environment.

The following tutorials will guide you through developing your first React-Native application for both iOS and Android, React-Native 0.44 is the version used.

Getting Started

For setting up the environment, install React-Native and required dependencies i.e home brew, node, watchman, Xcode and Android development environment refer Installation Link .

There are so many IDEs out there for development and it’s difficult for us to choose the right editor for a particular programming language. While working with React Native, I did some digging and found below IDEs which are suitable for mobile app development:

  1. SubLime
  2. Atom
  3. Visual Studio Code

We will proceed with macOS environment and Visual Studio Code IDE.

Creating a new application

Create a new folder in any specific location you wish using terminal with the following command

mkdir ReactProject
cd ReactProject
ReactProject~ react-native init HelloWorld
After Successful creation of Project

Running your React Native application

Let’s check if the application created works fine by compiling and building it on either iOS Simulator or Android emulator. There are two ways we can proceed as listed below:

  1. By React CLI in Terminal using commands.
cd HelloWorld

For iOS

HelloWorld~ react-native run-ios

For Android

HelloWorld~ react-native run-android

2. By VS code IDE.

Let’s import code folder in VS code IDE and make sure you have installed React-Native plugins in Extension Window(⌘ + ⇧ + x) before building the app.

Opening Project in VS Code IDE

After importing go to Debug window(⌘ + ⇧ + d) and select the Environment as React-Native which will create configuration file named “launch.json

Selecting Environment in VS Code IDE
Configuration file created by VS Code IDE

Finally we are done with the configuration setup in VS code IDE. Now, select the required platform from the Debug dropdown and click on Run

Running Application via VS Code IDE

Modifying your app

Now that you have successfully run the app, let’s modify it.

Note: main root file for iOS will be index.ios.js and for Android in the project structure.

That’s it!

You’ve successfully built and modified the first React Native app.