【发布时间】:2023-01-19 23:15:30
【问题描述】:
当我尝试在底部选项卡中添加图标时 https://icons.expo.fyi/ 它显示 Tab.Navigator 错误
This JSX tag's 'children' prop expects a single child of type 'ReactNode', but multiple children were provided.ts(2746)
我尝试添加
children: React.ReactNode;
但出现 ReactNode 错误
Property 'ReactNode' does not exist on type 'typeof React'.ts(2339)
这是 index.tsx 文件
const Tab = createBottomTabNavigator();
function BottomTabNavigator() {
return (
<Tab.Navigator>
<Tab.Screen name="Dashboard" component={DashboardScreen} />
screenOptions={({ route }) => ({
tabBarIcon: ({ focused, color, size }) => {
let iconName;
if (route.name === 'Dashboard') {
iconName = focused
? 'ios-speedometer'
: 'ios-speedometers';
} else if (route.name === 'Settings') {
iconName = focused ? 'ios-list' : 'ios-list-outline';
}
<Tab.Screen name="Settings" component={TabTwoScreen} />
</Tab.Navigator>
);
}
【问题讨论】:
标签: reactjs typescript react-native navigation children