找不到屏幕“用户"的“组件"、“getComponent"或“儿童"道具 [英] Couldn't find a 'component', 'getComponent', or 'children' prop for the screen 'User'
本文介绍了找不到屏幕“用户"的“组件"、“getComponent"或“儿童"道具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我很难弄清楚 React Native 的神秘错误消息的含义.我有大约三十分钟的以下错误,在我所有的谷歌搜索之后,我仍然不知道如何解决它:找不到屏幕用户"的组件"、getComponent"或儿童"道具'.
I am having a lot of trouble figuring out what React Native's cryptic error messages mean. I've had the following error for about thirty minutes and after all my googling I still don't know how to fix it: Couldn't find a 'component', 'getComponent', or 'children' prop for the screen 'User'.
我的应用模块:
import React, { useEffect, useState } from 'react';
import { ActivityIndicator, FlatList, Button, View, Text, Image, StyleSheet } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import { UserDetailScreen } from './app/screens/UserDetailScreen';
const Stack = createStackNavigator();
function MyStack() {
return (
<Stack.Navigator>
<Stack.Screen name="User" component={UserDetailScreen} />
</Stack.Navigator>
);
}
export default function App() {
console.log("test");
console.log(UserDetailScreen);
return (
<NavigationContainer>
<MyStack />
</NavigationContainer>
);
}
我的用户详细信息屏幕
import React from 'react';
import { SafeAreaView, View, StyleSheet } from 'react-native';
import { ActivityIndicator, FlatList, Button, Text, Image } from 'react-native';
import {styles} from '../assets/stylesheets/UserDetailStyles';
export default class UserDetailScreen extends React.Component<Props> {
render = ({ navigation }) => {...return components}
}
推荐答案
您正在导出 UserDetailScreen.js 中的默认类.像这样导入一个默认类:import UserDetailScreen from './app/screens/UserDetailScreen';
You are exporting a default class in UserDetailScreen.js. Import a default class like so: import UserDetailScreen from './app/screens/UserDetailScreen';
这篇关于找不到屏幕“用户"的“组件"、“getComponent"或“儿童"道具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文