我有一个“显示”屏幕,它有一个显示列表,单击“显示详细信息”页面。在细节页,它有3个标签,但一个是隐藏的,如果反馈是空白的。这会在导航到各种显示时抛出一个错误,这些节目有前馈,然后没有反馈:
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>
发布于 2022-02-04 14:29:45
我不知道它为什么不起作用,但我把它改成了
{ show.feedurl != '' && (
现在它起作用了,我很想知道为什么它不起作用。
发布于 2022-02-04 14:07:28
你能试着用这个替换你的.Screen代码吗?我从来没有使用bit本机或反应导航,但这是我通过一点研究发现的。
<ShowTab.Screen name="About" children={() => <ShowInfo show={show} />} />
<ShowTab.Screen name="Schedule" children={() => <ShowSchedule show={show} />} />
{show.feedurl && (
<ShowTab.Screen name="Podcasts" children={() => <ShowPodcasts show={show} />} />
)}
```
https://stackoverflow.com/questions/70987384
复制相似问题