With just one tap of figure, we can do much of the daily routine work like ordering food, book a cab and many more with the help of mobile. Mobile app business is predicted to generate $188.9 billion in global revenue by 2020 as compared to $88.3 billion in 2016 according to Statista. In this fastest growing mobile industry native android and iOS development is too much time consuming as we have to write the same app twice and we have to spend more money on developers too.
Advantages of React Native
Cross Platform Support
We can build react native app both in iOS and Android with native UI elements. There are some instances where we have to write platform specific functionality like different UI for iOS and Android. React native provides modules that can detect the supporting OS at runtime and run platform specific implementation.
While developing native iOS and Android in XCode and Android Studio respectively, if we want to apply the changes then we have to re run the whole app which more time consuming. But in react native hot reload functionality is available which can apply your changes faster than native any other tool available for app development.
Easy to learn
You can learn react native using online tool called expo which is created by Facebook. If you just want to learn react native quickly and don’t want to setup your machine for react native then expo is the best tool for you to start with. You just need Node.js and Expo CLI installed and you can start building application. But for Building projects with native code you will have to set up the react native properly in your machine. So we will quickly go through the set up process.
How to Set up Development Environment
You will need Node, Python2, JDK, React native command line interface and android studio for Android and Xcode for iOS. To build application for iOS you will require Mac machine. You can install node, python and JDK by using following command using Chocolatey.
Open Administrator command Prompt by right clicking Command Prompt and select “Run as Administrator” and past the following command. If you have already installed node in you system then you will have to make sure that it is Node 8.3 or newer. Also if you have already installed JDK in your machine then also you will have to make sure that it is version 8 or newer.
- Choco install –y nodejs.install python2 jdk8
You will have to install Node, Watchman and Homebrew if you are using Mac. You can install Node and Watchman using following commands.
- brew install node
- brew install watchman
Install React Native Command Line Interface
Paste and run the following command in Command Prompt or shell:
- npm install –g react-native-cli
Setup Android Studio and SDK
Download and install Android Studio from this site (Download). While installing android studio choose “custom” as installation.
Here you will require installing the Android 8.1(Oreo) SDK in particular as of now so make sure to install SDK from SDK manager. You can go to SDK manager as bellow. Click on “Configure” drop-down on welcome screen of Android Studio.
Installing Xcode and Command Line tools
Install the Xcode via Mac app store. If you have already installed it then make sure it is version 9.4 or newer. Now you will have to install command line tools by following this path.
- Xcode -> Preferences -> Locations
Now select the most recent version of command line tools and install it.
That’s it and you are good to go with creating project.
Creating a new Project
You can create new project using just one command. Go to the location where you want to create a project from command lines and past the following command and replace the ProjectName with you project’s name.
- react-native init ProjectName
Past and run the following command to run the project in Android device.
- cd ProjectName
- react-native run-android
Past and run the following command to run the project in iOS device.
- react-native run-ios
That’s it. It is so easy to create and start development in react native. Now we will look at some dis-advantage of the framework.
The documentation is not that up to mark that we can easy get something out of it. Framework is still in the growing stage so we will have to give it time to get mature. There are some features on iOS and Android still aren’t supported so we have to create our own modules for that. React native create another layer on top of you native project so there are some debugging issues.