我想创建一个 Top Tab 导航器并将两个屏幕 Badges.js 和 Studying.js 放入 Tab 当我在我的设备上运行它时我收到一个错误它说“错误:元素类型无效:需要一个字符串......”和"检查 `MaterialTopTabNavigator" 的渲染方法。
TabScreen.js
import React from 'react';
import {View, Image, Text} from 'react-native';
import {createMaterialTopTabNavigator} from '@react-navigation/material-top-tabs';
import Badges from './Badge';
import Studying from './Studying';
const Tab = createMaterialTopTabNavigator();
const TabsScreen = () => {
return (
<Tab.Navigator>
<Tab.Screen name="Badges" component={Badges} />
<Tab.Screen name="Studying" component={Studying} />
</Tab.Navigator>
);
};
export default TabsScreen;
徽章.js
import React from 'react';
import {View, Image, Text} from 'react-native';
const Badges = () => {
return (
<View>
<Text>Badges</Text>
</View>
);
};
export default Badges;
学习.js
import React from 'react';
import {View, Image, Text} from 'react-native';
const Studying = () => {
return (
<View>
<Text>Studying</Text>
</View>
);
};
export default Studying;