React Native is Facebook's open source framework for building native applications on iOS and Android. It achieves this by providing a common developer experience so that a developer learns one set of tools and can apply it to both platforms. It takes the component approach used by React and applies it to the mobile app world.

As part of our research and development work here at Black Pepper, we've been investigating how we can make use of React Native to write Android and iOS apps for our customers. Because we predominantly use Linux as our development environment, I ran into a few issues along the way and this guide will hopefully help others avoid the same pitfalls.

Why do we need this React Native guide?

Facebook have provided a great deal of information about React Native on github, however because it's early days for React Native, and Facebook use OS X for development, getting up and running on Linux isn't as straightforward as it should be. Additionally, the Android version of React Native hasn't been publicly available for very long, so there are fewer resources available.

Approach

I'm a big fan of using Docker to isolate tools, particularly when testing out something new. It also means you can get a new development up and running in no time; simply pull down the docker images you need. So to get up and running with React Native, I followed the Getting Started guide but added everything to a Dockerfile as I went.

The Docker image is created in such a way that it will have access to a directory on the host machine for code storage, allowing you to use whichever editor or IDE you prefer, along with any other day to day tools such as git. Additionally I made use of privileged mode so that the docker container will be able to access the USB ports of the host, so the React Native app can be run on a physical device, rather than just in the emulator.

Prerequisites

You'll need to have installed Docker and familiarised yourself with how it works if you want to try this out. You'll also need to have familiarised yourself with Android app development, React and React Native.

Installation

Currently the Dockerfile only exists in my personal github repo but I'm in the process of moving it to the Black Pepper repo and from there I'll publish the image so you'll be able to retrieve it with a simple "docker pull".

However, for the time being you can obtain and build the image as follows: