question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

undefined ImagePicker.ShowImagePicker , read all issue same as mine

See original GitHub issue

Hi I’ve read all issues , been still stuck for hours on this.

please help


import React, { Component } from 'react';
import { AppRegistry, ScrollView, Image, TouchableOpacity, StyleSheet, PixelRatio, View } from 'react-native';
import { Button, Icon, Divider, Card, Badge, Text} from 'react-native-elements';
import Moment from 'react-moment';
import * as firebase from 'firebase';
import Database from "../firebase/database";

import ImagePicker from 'react-native-image-picker'



export default class DetailsShift extends Component {


  state = {
    avatarSource: null,
    videoSource: null
  };

  selectPhotoTapped() {
    const options = {
      quality: 1.0,
      maxWidth: 500,
      maxHeight: 500,
      storageOptions: {
        skipBackup: true
      }
    };
  
    ImagePicker.showImagePicker(options, (response) => {
      console.log('Response = ', response);

      if (response.didCancel) {
        console.log('User cancelled photo picker');
      }
      else if (response.error) {
        console.log('ImagePicker Error: ', response.error);
      }
      else if (response.customButton) {
        console.log('User tapped custom button: ', response.customButton);
      }
      else {
        let source = { uri: response.uri };

        // You can also display the image using data:
        // let source = { uri: 'data:image/jpeg;base64,' + response.data };

        this.setState({
          avatarSource: source
        });
      }
    });
  }

  selectVideoTapped() {
    const options = {
      title: 'Video Picker',
      takePhotoButtonTitle: 'Take Video...',
      mediaType: 'video',
      videoQuality: 'medium'
    };

    ImagePicker.showImagePicker(options, (response) => {
      console.log('Response = ', response);

      if (response.didCancel) {
        console.log('User cancelled video picker');
      }
      else if (response.error) {
        console.log('ImagePicker Error: ', response.error);
      }
      else if (response.customButton) {
        console.log('User tapped custom button: ', response.customButton);
      }
      else {
        this.setState({
          videoSource: response.uri
        });
      }
    });
  }


  static navigationOptions =  {
    title: 'Shift Details',
    headerLeft: null,
    headerTintColor: "white",
    headerStyle: {
        backgroundColor: 'rgb(207, 90, 99)',
        elevation: null },   
    };
  render() {


    
    return (
      <ScrollView>


                <TouchableOpacity onPress={this.selectPhotoTapped}>
                <View style={[styles.avatar, styles.avatarContainer, {marginBottom: 20}]}>
                { this.state.avatarSource === null ? <Text>Select a Photo</Text> :
                  <Image style={styles.avatar} source={this.state.avatarSource} />
                }
                </View>
              </TouchableOpacity>



      </ScrollView>
    );
  }

  
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF'
  },
  avatarContainer: {
    borderColor: '#9B9B9B',
    borderWidth: 1 / PixelRatio.get(),
    justifyContent: 'center',
    alignItems: 'center'
  },
  avatar: {
    borderRadius: 75,
    width: 150,
    height: 150
  }
});

Can anyone help please, am i doing something wrong ?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
20chixcommented, Sep 16, 2017

Right I’m closing this issue as I found a different solution to upload Image with project created in Expo. I used this example which really helped me https://docs.expo.io/versions/latest/sdk/imagepicker.html. hope will be useful for someone in the future

0reactions
matheuscoutocommented, Nov 7, 2018

You upload base64 images to firebase, just get the response.uri and use the method:

firebase.storage().ref().child('randomPath')
	.putString(file, 'base64' ,{
		contentType: 'image/jpeg',
	});

That worked for me

Read more comments on GitHub >

github_iconTop Results From Across the Web

undefined ImagePicker.ShowImagePicker , read all issue ...
Hi I've read all issues , been still stuck for hours on this. please help import React, { Component } from 'react'; import...
Read more >
Why is react-native-image-picker's showImagePicker ...
In the terminal, project folder? I actually used react-native-image-picker for a previous project and installed and implmented it the exact same, and it...
Read more >
How to use the react-native-image-picker.showImagePicker ...
Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues...
Read more >
react-native-sensitive-info Cannot read property setItem of ...
Coding example for the question react-native-sensitive-info Cannot read property setItem of undefined.
Read more >
Example of Image Picker in React Native
Image Picker in React Native using ImagePicker component with options 1. Take Image, 2. Choose From Library, 3. Choose from Custom Options.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found