【发布时间】:2021-11-01 12:20:34
【问题描述】:
在我的 React Native App.js 中,我有以下代码
import { StatusBar } from 'expo-status-bar';
import React, { useRef, Component } from 'react';
import { StyleSheet, Text, View, Canvas } from 'react-native';
import { RNCamera } from "react-native-camera";
import * as tf from '@tensorflow/tfjs';
import * as handpose from '@tensorflow-models/handpose';
export default function App() {
const webcamRef = useRef(null);
const canvasRef = useRef(null);
return (
<View style={styles.container}>
<RNCamera ref={webcamRef}
style={{
position: 'absolute',
marginLeft: 'auto',
marginRight: 'auto',
left: 0,
right: 0,
textAlign: 'center',
zIndex: 9,
height: 480,
width: 640
}}
/>
<Canvas ref={canvasRef}
style={{
position: 'absolute',
marginLeft: 'auto',
marginRight: 'auto',
left: 0,
right: 0,
textAlign: 'center',
zIndex: 9,
height: 480,
width: 640
}}
/>
<StatusBar style="auto" />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
上面的代码说:
元素类型无效:应为字符串(对于内置组件)或类/函数(对于复合组件),但得到:未定义。您可能忘记从定义组件的文件中导出组件,或者您可能混淆了默认导入和命名导入
【问题讨论】:
标签: javascript reactjs react-native