Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports. #921

Closed
faheem121 opened this issue Sep 1, 2018 · 6 comments
Labels
stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@faheem121
Copy link

Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

Check your code at registerRootComponent.js:35.
in ExpoRootComponent (at renderApplication.js:33)
in RCTView (at View.js:60)
in View (at AppContainer.js:102)
in RCTView (at View.js:60)
in View (at AppContainer.js:122)
in AppContainer (at renderApplication.js:32)

My Code is:

import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
PixelRatio,
TouchableOpacity,
Image,
} from 'react-native';

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

class ImagePickerProject extends React.Component {

state = {

  ImageSource: 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({

        ImageSource: source

      });
    }
  });
}

render() {
  return (
    <View style={styles.container}>

      <TouchableOpacity onPress={this.selectPhotoTapped.bind(this)}>

        <View style={styles.ImageContainer}>

        { this.state.ImageSource === null ? <Text>Select a Photo</Text> :
          <Image style={styles.ImageContainer} source={this.state.ImageSource} />
        }

        </View>

      </TouchableOpacity>

    </View>
  );
}

}

const styles = StyleSheet.create({

container: {
  flex: 1,
  justifyContent: 'center',
  alignItems: 'center',
  backgroundColor: '#FFF8E1'
},

ImageContainer: {
  borderRadius: 10,
  width: 250,
  height: 250,
  borderColor: '#9B9B9B',
  borderWidth: 1 / PixelRatio.get(),
  justifyContent: 'center',
  alignItems: 'center',
  backgroundColor: '#CDDC39',
  
},

});

AppRegistry.registerComponent('ImagePickerProject', () => ImagePickerProject);

@faheem121
Copy link
Author

this issue is solve by putting export default but i got another issue
undefined is not an object (evaluating 'ImagePickerManager.showImagePicker')
Please Help

@terence612
Copy link

terence612 commented Sep 5, 2018

I met the same problem as you do when I was using react-native link and found out it was because of the pod was not install to the project. Go to the ios directory and run pod install after running react-native link.
Or you can try to install it manually, both actions solve my problem.

@stale
Copy link

stale bot commented Jun 11, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. You may also mark this issue as a "discussion" and I will leave this open.

@stale stale bot added the stale There has been a lack of activity on this issue and it may be closed soon. label Jun 11, 2019
@stale
Copy link

stale bot commented Jun 18, 2019

Closing this issue after a prolonged period of inactivity. Fell free to reopen this issue, if this still affecting you.

@stale stale bot closed this as completed Jun 18, 2019
@CajetanRodrigues
Copy link

Same issue

@kambleaa007
Copy link

issue is still there never fixed

@react-native-image-picker react-native-image-picker locked as resolved and limited conversation to collaborators Nov 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

4 participants