我有一个“节目”屏幕,其中包含节目列表,单击转到节目详细信息页面。在详细信息页面上,它有 3 个选项卡,但如果 feedurl 为空,则隐藏一个。当导航到具有 feedurl 的各种节目然后没有 feedsurl 时,这会引发错误:
Error: A navigator can only contain 'Screen', 'Group' or 'React.Fragment' as its direct children (found ''). To render this component in the navigator, pass it in the 'component' prop to 'Screen'.
我猜你不能有条件标签渲染?
<ShowTab.Navigator
screenOptions={{
tabBarActiveTintColor: 'white',
tabBarInactiveTintColor: '#4b7894',
tabBarLabelStyle: {
fontWeight: '600',
},
tabBarIndicatorStyle: {
backgroundColor: 'white',
height: 4,
},
tabBarStyle: {
backgroundColor: '#021f2e',
},
}}>
<ShowTab.Screen name="About">
{() => <ShowInfo show={show} />}
</ShowTab.Screen>
<ShowTab.Screen name="Schedule">
{() => <ShowSchedule show={show} />}
</ShowTab.Screen>
{show.feedurl && (
<ShowTab.Screen name="Podcasts">
{() => <ShowPodcasts show={show} />}
</ShowTab.Screen>
)}
</ShowTab.Navigator>