Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs (警告:React.createElement:类型无效)React本机错误_Reactjs_React Native_Expo_Face Detection - Fatal编程技术网

Reactjs (警告:React.createElement:类型无效)React本机错误

Reactjs (警告:React.createElement:类型无效)React本机错误,reactjs,react-native,expo,face-detection,Reactjs,React Native,Expo,Face Detection,在使用expo创建的react本机应用程序中,我尝试在运行时实现面部登录功能。我已附加我的App.js文件,您可以尝试运行此应用程序。在运行应用程序时使用 世博会开幕 我得到以下错误。请帮助我,我不确定是什么导致了这个错误 App.js 从“React”导入React; 从“react native”导入{样式表、文本、视图、振动}; 从“expo”导入{MediaLibrary}; 从“世博相机”导入相机; 从“expo人脸检测仪”导入*作为人脸检测仪; 从“expo常量”导入*作为常量;

在使用expo创建的react本机应用程序中,我尝试在运行时实现面部登录功能。我已附加我的App.js文件,您可以尝试运行此应用程序。在运行应用程序时使用

世博会开幕

我得到以下错误。请帮助我,我不确定是什么导致了这个错误

App.js

从“React”导入React;
从“react native”导入{样式表、文本、视图、振动};
从“expo”导入{MediaLibrary};
从“世博相机”导入相机;
从“expo人脸检测仪”导入*作为人脸检测仪;
从“expo常量”导入*作为常量;
从“expo Permissions”导入*作为权限;
常数barHeight=常数.statusBarHeight;
导出默认类App扩展React.Component{
状态={
hasCameraPermission:null,
hasCameraRollPermissions:null,
面:[],
是的,
}
异步组件willmount(){
const{status}=wait Permissions.askAsync(Permissions.CAMERA);
const{cameraRollStatus}=wait Permissions.askAsync(Permissions.CAMERA_ROLL)
这是我的国家({
hasCameraPermission:状态==='已授予',
hasCameraRollPermissions:cameraRollStatus===“已授予”
});
}
渲染面=()=>
{this.state.faces.map(this.renderFace)}
renderFace({bounds,faceID,rollAngle,yawAngle}){
返回(
rollAngle:{rollAngle.toFixed(0)}
yawAngle:{yawAngle.toFixed(0)}
);
}
handleFacesDetected=({faces})=>{
如果(faces.length>=0){
此。detectFaces(错误);
this.setState({faces});
这张照片;
}
};
拍照=()=>{
这是我的国家({
图片肯:是的,
});
如果(这个相机){
this.camera.takePictureAsync({onPictureSaved:this.onPictureSaved});
}
}
onPictureSaved=异步(数据)=>{
const asset=wait mediabrary.createAssetSync(data.uri);
控制台日志(“资产”,资产);
MediaLibrary.createAlbumAsync('MyFace',资产)
.然后(()=>{
此。detectFaces(真);
振动;
})
.catch(错误=>{
此。detectFaces(真);
振动;
});
}
检测面(doDetect){
这是我的国家({
面部检测:doDetect,
});
}
render(){
const{hasCameraPermission,faces,faceDetecting}=this.state;
if(hasCameraPermission===null){
返回请求相机许可;
}else if(hasCameraPermission===false){
不允许进入摄像机;
}否则{
返回(
{this.camera=ref}}>
x:{this.state.faces.length?this.state.faces[0].bounds.origin.x.toFixed(0):0}
y:{this.state.faces.length?this.state.faces[0].bounds.origin.y.toFixed(0):0}
高度:{this.state.faces.length?this.state.faces[0].bounds.size.height.toFixed(0):0}
宽度:{this.state.faces.length?this.state.faces[0].bounds.size.width.toFixed(0):0}
{`视图中的面:${Faces.length}`}
{faceDetecting&&this.state.faces.length?this.renderface():未定义}
);
}
}
}
const styles=StyleSheet.create({
容器:{
弹性:1,
背景颜色:“#000”,
},
摄像机:{
弹性:1,
justifyContent:'之间的空间',
},
顶栏:{
弹性系数:0.2,
背景色:“透明”,
flexDirection:'行',
为内容辩护:“周围的空间”,
填充顶:杆高+1,
},
底线:{
弹性系数:0.2,
背景色:“透明”,
flexDirection:'行',
为内容辩护:“周围的空间”,
},
脸:{
填充:10,
边框宽度:1,
边界半径:1,
位置:'绝对',
边框颜色:“#808000”,
为内容辩护:“中心”,
背景色:“透明”,
},
faceText:{
颜色:“#32CD32”,
fontWeight:'粗体',
textAlign:'中心',
差额:10,
背景色:“透明”,
},
面部容器:{
位置:'绝对',
底部:0,
右:0,,
左:0,,
排名:0,
},
文本颜色:{
颜色:'#008080',
}
});
expo摄像头上
未处于默认导出状态,请更改导入

import Camera from 'expo-camera'

上的
expo camera
未处于默认导出状态,请更改导入

import Camera from 'expo-camera'


我已经更新了代码,就像你说的。它修好了。非常感谢。但是,我遇到了另一个错误,如“来自JS的错误调用:字段大小不同”。我将更新屏幕截图供您参考。看起来
barHeight
value未定义/null,请尝试使用静态值更改样式
paddingTop
。我已更新了代码,如您所说。它修好了。非常感谢。但是,我遇到了另一个错误,如“来自JS的错误调用:字段大小不同”。我将更新屏幕截图供您参考。看起来
barHeight
value未定义/null,请尝试使用静态值更改样式
paddingTop