JSPM

react-native-image-chooser

1.0.4
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 23
  • Score
    100M100P100Q42008F

A react-native module for showing system image chooser.

Package Exports

  • react-native-image-chooser

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-native-image-chooser) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

react-native-image-chooser

A React Native module to show system Image chooser. Currently only supports Android.

Installation

npm i --save react-native-image-chooser

Add it to your android project

In android/settings.gradle

...

include ':react-native-image-chooser'
project(':react-native-image-chooser').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-image-chooser/android')

In android/app/build.gradle

...

dependencies {
    ...

    compile project(':react-native-image-chooser')
}

Register module (in MainActivity.java)

import com.imagechooser.ImageChooserPackage;  // <--- import

public class MainActivity extends ReactActivity {

  ......

  @Override
  protected List<ReactPackage> getPackages() {
    return Arrays.asList(
      new MainReactPackage(),
      new ImageChooserPackage() // <------ add the package
    );
  }

  ......

}

Usage

First import the module as follows:

import ImageChooser from "react-native-image-chooser";

To show the chooser, call the pickImage method:

try {
  const data = await ImageChooser.pickImage();

  // do something with the data
} catch (err) {
  // handle error
}

The pickImage method returns a Promise with data. The data object has the following properties:

height: number;
width: number;
size: number;
name: string;
uri: string;