Skip to content

Latest commit

 

History

History
58 lines (47 loc) · 1.45 KB

README.md

File metadata and controls

58 lines (47 loc) · 1.45 KB

react-native-directory-picker

A React Native module that allows you to use native UI to select a directory from the device library

⚠️ Using this component is not recommended. This is a workaround.

Install

Android

$ npm install git+https://github.com/lokdevp/react-native-directory-picker.git
$ react-native link
<!-- file: android/src/main/AndroidManifest.xml -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.myApp">
    <!-- add following permissions -->
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <!-- -->
    ...

Usage

  1. In your React Native javascript code, bring in the native module:
import DirectoryPickerManager from 'react-native-directory-picker';
  1. Use it like so:

When you want to display the picker:

DirectoryPickerManager.showDirectoryPicker(null, (response) => {
  console.log('Response = ', response);

  if (response.didCancel) {
    console.log('User cancelled directory picker');
  }
  else if (response.error) {
    console.log('DirectoryPickerManager Error: ', response.error);
  }
  else {
    this.setState({
      directory: response
    });
  }
});

News

Compatible with Android X

Compatible with all versions of RN

Compatible with files from Google Drive

Requesting permission if not exist

Retrieving fileName and file type