Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

rn-camera

julioxavierr6MIT0.0.2

Simple camera native module for React Native

readme

rn-camera

With rn-camera you are able access the camera and image library of iOS and Android devices using simple JavaScript functions.

Installation

Install the package as a dependency of your project:

npm install rn-camera

Link the native module:

react-native link rn-camera

Open camera

import Camera from 'rn-camera';

const [image, setImage] = useState(null);

Camera.openCamera({ save: true, quality: 1.0, frontCamera: false }, (result) => {
  setImage(result.uri);
});

The first parameter is an object that defines configuration for the camera, it accepts the following fields:

Option field Description Default Platform
save saves photo in camera row (optional) true iOS / Android
quality defines the quality of the photo using values from 0.0 to 1.0 (optional) 1.0 iOS / Android
frontCamera start camera using frontal camera (optional) false iOS

Open Image Library

import Camera from 'rn-camera';

const [image, setImage] = useState(null);

Camera.openImageLibrary({}, (result) => {
  setImage(result.uri);
});

There's also available an example project using the native module.