DEV Community

Chandrasekar Kuppusamy
Chandrasekar Kuppusamy

Posted on • Originally published at blog.f22labs.com on

Getting started with React Native for Mac

As we all know that Facebook is the creator of react native, which lets you build apps using Javascript for both iOS and Android.

Tools and development environment?

Similar to other framework and programming languages, the React Native expects the following things that has to be setup as a beginner.

1. Xcode

Do you wanna build apps for iOS as well? Then please go ahead with the Xcode installation from the app store. Hey! Again I support only for Mac. Sadly no support for Windows, Linux and other platforms.

2.Brew

Brewing coffee even takes some time but installing or updating apps are easy with Brew. Yeah! It provides an easy option to install softwares, packages, SDK’s and libraries using simple commands on iTerm.

For example:

brew install mysql  — Installs mysql into your mac.

brew update mysql  — Updates mysql to latest version.

brew cask install google-chrome  — Installs Google chrome.

3. Node/NPM

Oooh! Here comes the main warrior who actually helps to make Javascript work outside the browser environment and NPM manages the dependencies.

Let’s take this ahead and see further to install Node on your machine.

brew install node  — This installs node and other related packages to your Mac. (Really Brew made it simple!).

It’s time to verify your installation of the node using node -v command from a terminal. It should say v8.8.1 or any versions which is installed.

4. Watchman

Watchman is a tool by Facebook for watching changes in the filesystem. It keeps an eye on the modified changes or updates that are made to particular files.

brew install watchman  — This installs watchman to your mac.

5. Editors (Sublime or Atom or Vscode)

Though there are few IDE exists like Deco, the editors like Sublime or Atom provides ample amount of customisation when it comes to Auto suggestion, lint, error correction, etc. I prefer Atom for React Native development. (Not really biased ;-))

6. The React Native CLI

Node comes with npm, which lets you install the React Native command line interface.

Run the following command in a Terminal:

npm install -g react-native-cli

7. Lint/ESLint

This is one of the cool feature with Atom, which lets you know when you’re helpless or stuck while coding by pointing your syntax errors.

Setup:

  1. Navigate to root project and enter npm install — save-dev eslint-config-standard

  2. Create .eslintrc in the project root folder and paste the following snippet

{
  "extends": "standard"
}
Enter fullscreen mode Exit fullscreen mode

For example:

I have a habit of missing or closing brackets ‘()’

Failed to add semicolons ‘;’

Installation : Navigate to Atom — Preferences — Install — Search for eslint and Install in your Atom

Some common React Native Terminal Commands?

  1. react-native init HelloWorld  — Creates new React Native project
  2. react-native run - ios _—_Build and run the React Native project in your iOS simulator or device (Fingers crossed if XCode is not installed or updated properly)
  3. react-native run - android  — Build and run the React Native project in your Android emulator or device (Make sure your Android Sdk and Gradle are installed)
  4. npm install — — save-dev eslint-config-standard —  Used to configure elslint in atom
  5. npm start — — reset-cache  — Reset Cache
  6. npm install — — save redux react-redux —  Enables redux support
  7. npm install native-base — save - Initialise Native Base libray

Happy coding!


Top comments (0)