永久违反:缺少导航道具

时间:2019-07-04 10:23:02

标签: react-native

在主流程中,我的应用程序中有两个流程。一个是堆栈导航,另一个是抽屉式导航。堆栈导航可以正常工作,但是抽屉一个给我这个错误-

不变违反:此导航器缺少导航道具。在react-navigation第3版中,您必须直接设置应用容器。更多信息: https://reactnavigation.org/docs/en/app-containers.html

App.js

import { createAppContainer,
         createStackNavigator , 
         createBottomTabNavigator,
         createDrawerNavigator,
         createSwitchNavigator
       } from "react-navigation";
import LoginScreen from "./src/screens/LoginScreen";
import RegisterScreen from "./src/screens/RegisterScreen";
import StartScreen from './src/screens/StartScreen';
import { HomeDrawerNavigator } from "./src/components/HomeDrawerNavigator";

const MainNavigator = createSwitchNavigator(
  {
    loginFlow: { 
      screen: createStackNavigator(
        {
          StartScreen :{screen:StartScreen
            },
          LoginScreen : {screen : LoginScreen},
          RegisterScreen : {screen : RegisterScreen}
        }
      )
    },
    homeflow: {
      screen:HomeDrawerNavigator
    }

  }
)



const App = createAppContainer(MainNavigator);
export default App;

HomeDrawerNavigator.js

import { createDrawerNavigator } from "react-navigation";
import HomeScreen from "../screens/HomeScreen";
import PolicyScreen from "../screens/PolicyScreen";

export const HomeDrawerNavigator = createDrawerNavigator({
  HomeScreen: { screen: HomeScreen },
  PolicyScreen: { screen: PolicyScreen }
})

我还在<HomeDrawerNavigator/>中添加了Homescreen.js组件。

0 个答案:

没有答案