错误:元素类型无效:应为字符串(对于内置组件)或类/函数(对于复合组件),但得到:您可能忘记了从定义组件的文件中导出组件,或者您可能混淆了默认导入和命名导入。
检查Details
的渲染方法。
下面我附上的代码。我已经仔细检查了一切仍然是给错误。我不知道是什么问题在渲染Details.js
这是App.js代码。
import * as React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import HomeScreen from './Home';
import DashboardScreen from './Dashboard'
import DetailsScreen from './Details';
const Stack = createNativeStackNavigator();
const MyStack = () => {
return (
<NavigationContainer>
<Stack.Navigator>
<Stack.Screen name="Details" component={DetailsScreen}/>
<Stack.Screen
name="Home"
component={HomeScreen}
options={{ title: 'Welcome' }}
/>
<Stack.Screen name="Dashboard" component={DashboardScreen} />
</Stack.Navigator>
</NavigationContainer>
);
};
export default MyStack
下面是Details.js代码。
import React from "react";
import { Text,View} from "react-native-paper";
const Details = () => {
return(
<View style = {{flex: 1,justifyContent:'center',alignItems:'center'}}>
<Text>
Enter Details Here
</Text>
</View>
)
}
export default Details;
1条答案
按热度按时间iecba09b1#
在您的Details.js中更改
至