[英]how to handle deeply nested navigation
Hi Im trying to make my first app with React-Native But I'm new on React-Native and React also so i dont know much about it.嗨,我正在尝试使用 React-Native 制作我的第一个应用程序,但我是 React-Native 和 React 的新手,所以我对此不太了解。
I having a problem with nested navigation.我有嵌套导航的问题。
I summarize the source to explain an error easier.我总结了来源以更容易地解释错误。
<Tab.Navigator>
<Tab.Screen name='Tab1' component={StackNav}/>
<Tab.Screen name='Tab2' component={TabScreen}/>
</Tab.Navigator>
function StackNav(){
return(
<Stack.Navigator>
<Stack.Screen name='Screen1'>
<ScreenList/> ----> this part is an error
</Stack.Navigator>
);
}
function Screen1(){
return(
<View><Text>This is Screen1</Text></View>
);
}
function ScreenList(){
return(
<Stack.Screen name='Screen2' component={Screen2}/>
<Stack.Screen name='Screen3' component={Screen3}/>
);
}
I am having and error like this我有这样的错误
A navigator can only contain 'Screen' components as its direct children (found 'ScreenList').导航器只能包含“屏幕”组件作为其直接子级(找到“屏幕列表”)。 To render this component in the navigator, pass it in the 'component' prop to 'Screen'.要在导航器中呈现此组件,请将其在“组件”道具中传递给“屏幕”。
i want to send a ScreenList with a function ScreenList() but the error said I can't send a screen我想发送带有 function ScreenList() 的 ScreenList,但错误提示我无法发送屏幕
how can I send a Screen list by function???如何通过 function 发送屏幕列表???
or is there any better way to navigate screen in nested navigation??还是有更好的方法在嵌套导航中导航屏幕?
function StackNav(){
return(
<Stack.Navigator>
<Stack.Screen name='Screen1' component={ScreenList}/>
</Stack.Navigator>
);
}
Please refer to the stack navigation documentation in react navigation site.请参阅 react 导航站点中的堆栈导航文档。 And replace this StackNav()
function with your StackNav()
function.并用您的StackNav()
function 替换此StackNav()
) function。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.