Communication between native and React Native

In Integrating with Existing Apps guide and Native UI Components guide we learn how to embed React Native in a native component and vice versa. When we mix native and React Native components, we'll eventually find a need to communicate between these two worlds. Some ways to achieve that have been already mentioned in other guides. This article summarizes available techniques. Introduction React Native is inspired by React, so the basic idea of the information flow is similar. The flow in Reac

DatePickerAndroid.dateSetAction()

static dateSetAction() A date has been selected.

Clipboard.setString()

static setString(content) Set content of string type. You can use following code to set clipboard content _setContent() { Clipboard.setString('hello world'); } @param the content to be stored in the clipboard.

Colors

The following formats are supported: '#f0f' (#rgb) '#f0fc' (#rgba) '#ff00ff' (#rrggbb) '#ff00ff00' (#rrggbbaa) 'rgb(255, 255, 255)' 'rgba(255, 255, 255, 1.0)' 'hsl(360, 100%, 100%)' 'hsla(360, 100%, 100%, 1.0)' 'transparent' 'red' 0xff00ff00 (0xrrggbbaa) For the named colors, React Native follows the CSS3 specification: aliceblue (#f0f8ff) antiquewhite (#faebd7) aqua (#00ffff) aquamarine (#7fffd4) azure (#f0ffff) beige (#f5f5dc) bisque (#ffe4c4) black (#000000) blanched

CameraRoll.saveImageWithTag()

static saveImageWithTag(tag) Saves the image to the camera roll / gallery. On Android, the tag is a local URI, such as "file:///sdcard/img.png". On iOS, the tag can be one of the following: local URI assets-library tag a tag not matching any of the above, which means the image data will be stored in memory (and consume memory as long as the process is alive) Returns a Promise which when resolved will be passed the new URI.

Clipboard.getString()

static getString() Get content of string type, this method returns a Promise, so you can use following code to get clipboard content async _getContent() { var content = await Clipboard.getString(); }

CameraRoll.getPhotos()

static getPhotos(params) Returns a Promise with photo identifier objects from the local camera roll of the device matching shape defined by getPhotosReturnChecker. @param {object} params See getPhotosParamChecker. Returns a Promise which when resolved will be of shape getPhotosReturnChecker.

Building React Native from source

You will need to build React Native from source if you want to work on a new feature/bug fix, try out the latest features which are not released yet, or maintain your own fork with patches that cannot be merged to the core. Prerequisites Assuming you have the Android SDK installed, run android to open the Android SDK Manager. Make sure you have the following installed: Android SDK version 23 (compileSdkVersion in build.gradle) SDK build tools version 23.0.1 (buildToolsVersion in build.gradle)

BackAndroid.exitApp()

static exitApp()

BackAndroid.removeEventListener()

static removeEventListener(eventName, handler)