Starting with React-Native(iOS/Android)
Major Advantages of React-Native
- 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.
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:
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
ReactProject~ react-native init HelloWorld
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:
- By React CLI in Terminal using commands.
HelloWorld~ react-native run-ios
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.
After importing go to Debug window(⌘ + ⇧ + d) and select the Environment as React-Native which will create configuration file named “launch.json”
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
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 index.android.js in the project structure.
You’ve successfully built and modified the first React Native app.