Javascript 反应本机错误-检查'App'的呈现方法`
我正在通过Javascript 反应本机错误-检查'App'的呈现方法`,javascript,react-native,expo,render,Javascript,React Native,Expo,Render,我正在通过expo start命令运行我的react native expo managed项目,我不知道我的代码中有什么错误导致了这个错误- Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your co
expo start
命令运行我的react native expo managed项目,我不知道我的代码中有什么错误导致了这个错误-
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. 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 the render method of `App`.
This error is located at:
in App (created by ExpoRoot)
in ExpoRoot (at renderApplication.js:45)
in RCTView (at View.js:34)
in View (at AppContainer.js:106)
in RCTView (at View.js:34)
in View (at AppContainer.js:132)
in AppContainer (at renderApplication.js:39)
这是我的密码-
export default function App() {
let [fontsLoaded] = useFonts({
'PoetsenOne-Regular': require('./assets/fonts/PoetsenOne-Regular.ttf'),
});
if (!fontsLoaded) {
return <AppLoading />;
} else{
return (
<View style={styles.container}>
<Text style={styles.container}>Open up App.js to start working on your app!</Text>
<StatusBar style="auto" />
</View>
);
}
}
所以,我自己解决了这个问题,问题是if-else语句-
if (!fontsLoaded) {
return <AppLoading />;
}
如果(!fontsLoaded){
返回;
}
当我删除它时,错误本身就解决了,
返回代码>是错误的主要原因,因为它没有正确导入,我导入了import{AppLoading}从“expo”
而不是从“expo app loading”导入应用程序
你的应用程序是什么?@Konstantin这是一个我已经导入的函数,它与我的代码没有问题你正确导入了应用程序吗?@AlexHill是的,这是真正的问题,我早些时候自己解决了这个问题,但仍然感谢你的帮助
if (!fontsLoaded) {
return <AppLoading />;
}