react-native-fast-image-picker
v0.1.0
Published
Support for Pick Image
Readme
react-native-fast-image-picker
A lightweight React Native library for picking single or multiple images using Nitro Modules.
Installation
npm install react-native-fast-image-picker react-native-nitro-modules
> `react-native-nitro-modules` is required as this library relies on [Nitro Modules](https://nitro.margelo.com/).For Android
android/src/main/java/....AndroidManifest.xml add
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />At android/src/main/java/...MainActivity.kt
import com.margelo.nitro.fastimagepicker.FastImagePicker
import android.content.Intent
....
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
FastImagePicker.instance?.onActivityResult(requestCode, resultCode, data)
}
...For IOS
Goto Info.plist Add
<key>NSPhotoLibraryUsageDescription</key>
<string>We need access to your photo library to select images.</string>
<key>Privacy - Photo Library Usage Description</key>
<string>We need access to your photo library to select images.</string>Usage
import { Button, StyleSheet, View } from 'react-native';
import { pickImage, pickMultipleImage } from 'react-native-fast-image-picker';
export default function App() {
return (
<View style={styles.container}>
<Button
title="Pick Single Image"
onPress={async () => {
try {
const result = await pickImage();
console.log('Single Image:', result);
} catch (error) {
console.log('Error picking image:', error);
}
}}
/>
<Button
title="Pick Multiple Images"
onPress={async () => {
try {
const result = await pickMultipleImage();
console.log('Multiple Images:', result);
} catch (error) {
console.log('Error picking images:', error);
}
}}
/>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
});
License
MIT
