Quantcast
Channel: Active questions tagged react-native+android - Stack Overflow
Viewing all articles
Browse latest Browse all 29448

React Native Image Picker: null is not an object (evaluating 'ImagePickerManager.showImagePicker')

$
0
0

I installed react-native-image-picker according to the documentation. When I am trying to select the image from the phone (after hitting the button), the emulator is giving me this error- null is not an object (evaluating 'ImagePickerManager.showImagePicker')

My React native's version is 0.59.8

and image picker's version is 0.28.0

this the code-

import React, { Component } from 'react';
import {
  StyleSheet,
  Text,
  View,
  Image,
  Button
} from 'react-native';
import ImagePicker from "react-native-image-picker";

export default class App extends Component {

  state = {
    pickedImage: null
  }

  reset = () => {
    this.setState({
      pickedImage: null
    });
  }




pickImageHandler = () => {
    ImagePicker.showImagePicker({title: "Pick an Image", maxWidth: 800, maxHeight: 600}, res => {
      if (res.didCancel) {
        console.log("User cancelled!");
      } else if (res.error) {
        console.log("Error", res.error);
      } else {
        this.setState({
          pickedImage: { uri: res.uri }
        });

      }
    });
  }



       resetHandler = () =>{
            this.reset();
          }

  render() {
    return (
      <View style={styles.container}>
      <Text style={styles.textStyle}>Pick Image From Camera and Gallery </Text>
        <View style={styles.placeholder}>
          <Image source={this.state.pickedImage} style={styles.previewImage} />
        </View>
        <View style={styles.button}>

          <Button title="Pick Image" onPress={this.pickImageHandler} />

          <Button title="Reset" onPress={this.resetHandler} />

         </View>
      </View>
    );
  }
}


Viewing all articles
Browse latest Browse all 29448

Trending Articles