尝试在 react native/native base 的 switchNavigator 中嵌套抽屉导航器时出错
Error when trying to nest a drawer navigator in a switchNavigator in react native/native base
当 运行 我的 IOS 应用程序在模拟器中时,我收到此错误。
这是我的相关代码。
import {createSwitchNavigator, createAppContainer} from "react-navigation"
import SideBar from "../App/Components/SideBar"
import createDrawerNavigator from "react-navigation-drawer";
//Components
import Login from "../App/Views/Login"
import Categories from "../App/Views/Categories"
import UserProfile from "../App/Views/UserProfile"
const BataDrawerNagivator = createDrawerNavigator({
Dashboard: {screen: SideBar }
});
const BataNavigator = createSwitchNavigator({
LoginScreen: Login,
CategoriesScreen: Categories,
UserProfileScreen: UserProfile,
Dashboard:{ screen: BataDrawerNagivator}
});
export default createAppContainer(BataNavigator);
我已经阅读了多个存在相同错误的在线资源,但所有答案似乎都指的是已弃用的依赖项,我认为这里不是这种情况。
有趣的是,每个导航单独运行良好,但当我尝试嵌套它们时,它会抛出此错误。
您收到此错误是因为您错误地导入了 createDrawerNavigator
变化
import createDrawerNavigator from "react-navigation-drawer";
至
import {createDrawerNavigator} from "react-navigation-drawer";
希望对您有所帮助!
当 运行 我的 IOS 应用程序在模拟器中时,我收到此错误。
这是我的相关代码。
import {createSwitchNavigator, createAppContainer} from "react-navigation"
import SideBar from "../App/Components/SideBar"
import createDrawerNavigator from "react-navigation-drawer";
//Components
import Login from "../App/Views/Login"
import Categories from "../App/Views/Categories"
import UserProfile from "../App/Views/UserProfile"
const BataDrawerNagivator = createDrawerNavigator({
Dashboard: {screen: SideBar }
});
const BataNavigator = createSwitchNavigator({
LoginScreen: Login,
CategoriesScreen: Categories,
UserProfileScreen: UserProfile,
Dashboard:{ screen: BataDrawerNagivator}
});
export default createAppContainer(BataNavigator);
我已经阅读了多个存在相同错误的在线资源,但所有答案似乎都指的是已弃用的依赖项,我认为这里不是这种情况。
有趣的是,每个导航单独运行良好,但当我尝试嵌套它们时,它会抛出此错误。
您收到此错误是因为您错误地导入了 createDrawerNavigator 变化
import createDrawerNavigator from "react-navigation-drawer";
至
import {createDrawerNavigator} from "react-navigation-drawer";
希望对您有所帮助!