An error has occurred: Element type is invalid. Expected a string (for built-in components) or a class/function (for composite components), but received undefined. This may be due to forgetting to export the component from the defining file, or possibly mixing up default and named imports.
Please check the render method of Application
.
enter code here
import React, { Component } from 'react';
import { View, StatusBar, TouchableOpacity, Image } from 'react-native';
import Camera from 'react-native-camera';
import styles from './styles';
import PhotoCaptureIcon from '../assets/ic_photo_camera_36pt.png';
export default class Application extends Component {
constructor(props){
super();
this.camera=null;
}
takePicture= () =>{
if(this.camera){
this.camera.capture()
.then((Data)=> console.log(data))
.catch(err=> console.error(err));
}
}
render(){
return (
<View style={styles.container}>
<StatusBar animated hidden />
<Camera
ref={(cam) => {
this.camera = cam;
}}
style={styles.preview}
/>
<View style={[styles.overlay, styles.bottomOverlay]}>
<TouchableOpacity style={styles.captureButton} onPress= {this.takePicture}>
<Image source={PhotoCaptureIcon} />
</TouchableOpacity>
</View>
</View>
);
}
}