首页 > 解决方案 > 如何在 React-Native 模态中定义 Stack Navigator?

问题描述

我想在我的 React-native 模态中使用堆栈导航器。有什么办法可以解决我的问题吗?

标签: react-nativemodal-dialog

解决方案


我认为你的方法是错误的。您可以将新场景添加到您的 stackNavigator 并设置为 mode:'modal' 和 headerShown: false 使用此道具,您可以将场景作为模态打开。同样使用此方法,您可以将此场景用作自定义模态并对其进行修改。
这是示例:

<WorkFormNavigator.Navigator {...props} mode="modal">
  <WorkFormNavigator.Screen
    name={Modules.WorkForm.WorkForms}
    component={WorkForms}
    options={{title: ModuleScreenNames.WorkForms, headerShown: false}}
  />

如果您打算在模态(导航道具)中使用导航,您可以获取道具并将它们发送到您的模态,现在您可以在此处使用它们。

const MyScene = ({navigation}) => {}
export default MyScene;

推荐阅读