Search code examples
javascriptreact-nativegallery

React Native - Cameraroll does not showing pictures


I am trying to show gallery images in my react native app but it does not showing any thing. Here's my code which I did for the gallery images.

import React, { Component } from 'react';
import { StyleSheet,Text,View } from 'react-native';

import CameraRollPicker from 'react-native-camera-roll-picker';

export default class Gallery extends Component{
    getSelectedImages(image){
        if(image[0])
            alert(image[0].uri);
    }
    render(){
        return(
            <CameraRollPicker callback={this.getSelectedImages}/>
        );
    }
}

When I run this into emulator/simulator or to my devices, it only shows a loader.

If anyone know the answer please help me.


Solution

  • Set permissions :

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    

    and here is my code :

    <CameraRollPicker
        scrollRenderAheadDistance={10000}
        initialListSize={1}
        pageSize={3}
        batchSize={5}
        maximum={3}
        selected={this.state.selected}
        assetType='All'
        imagesPerRow={3}
        imageMargin={5}
        callback={this.getSelectedImages} 
        selectSingleItem
    />