Getting started with React native
I am using
Windows 10 AndroidInstallation
Installation is pretty simple. There are two ways to create an application, using expo-cli and react-native-cli. I prefer the second one. It seems like a little complex but when developing large application it's the best way to start.
As a prerequisite we need to install nodeJS, Python, JDK and need to setup Android. We need to install react-native-cli globally for creating and running the project
npm install -g react-native-cli
Once you install the cli we can create the application.
react-native init firstProjectAfter creating the application we can move into the application folder and run the application. Before running the application we need a running emulator or a device connected to the system.
cd firstProject react-native run-androidVoila you could see the application in the emulator/device.
Debugging is pretty easier. There is remote debugging is possible in RN. On emulator just run
Ctrl + Mit will show menu with "Debug JS Remotely". Select the option it will open the debugger window on the browser. If the debugger not loading try
On Device run the following command on the shell
adb shell input keyevent 82
Debugging the http network is little bit tricky. I use Reactotron which is basically a good way to check the request/response of each http calls. In Windows for installing got the releases page and download the appropriate zip. Unzip it in a convenient place and add the folder it to the ENVIRONMENT VARIABLES. Once you added, you can run the app from bash/command. Before running you need import config file in the index.js or app.js. I generally add in the index.js.
You need to install the reactotron-react-native
npm install reactotron-react-native --save-devSample config file looks something like this
import Reactotron from 'reactotron-react-native'; Reactotron .configure() // controls connection & communication settings .useReactNative() // add all built-in react native plugins .connect() // let's connect!Also you may have to run the following command to connect to the port
adb reverse tcp:9090 tcp:9090On Production release you have to comment the import unless it will have some performance issues.
So that's it. Try react-native!