我在安装了一些与react-navigation相关的依赖项后出现错误

xkftehaa  于 2022-12-24  发布在  React
关注(0)|答案(1)|浏览(138)

_reactNative.Dimensions.removeEventListener is not a function.这是控制台抛出的错误,它没有说任何关于导航或任何与我的代码相关的东西,这就是为什么我认为是一个依赖性问题,请帮助。
这是我拥有的一些依赖项

"react-navigation": "^4.4.4",
    "react-navigation-stack": "^2.10.4",
    "react-navigation-tabs": "^2.11.2",

error displayed in console
我试着安装其他版本,但我需要那些教程我下面,它可能不会更新虽然

mwg9r5ms

mwg9r5ms1#

在这里你去伙计们,我想通了,我现在使用的React导航版本6和代码是这样的。

import React from "react";
    import { createStore } from "redux";
    import { Provider } from "react-redux";
    import HomeScreen from "./screens/HomeScreen";
    import SectionScreen from "./screens/SectionScreen";
    import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
    import { NavigationContainer } from "@react-navigation/native";
    import Ionicons from "@expo/vector-icons/Ionicons";
    
    const initialState = {
      action: "",
      name: "",
    };
    
    const reducer = (state = initialState, action) => {
      switch (action.type) {
        case "OPEN_MENU":
          return { action: "openMenu" };
        case "CLOSE_MENU":
          return { action: "closeMenu" };
        case "UPDATE_NAME":
          return { name: action.name };
        default:
          return state;
      }
    };
    
    const store = createStore(reducer);
    
    const Tab = createBottomTabNavigator();
    
    const App = () => (
      <Provider store={store}>
        <NavigationContainer>
          <Tab.Navigator
            screenOptions={({ route }) => ({
              tabBarIcon: ({ focused, color, size }) => {
                let iconName;
                if (route.name === "Home") {
                  iconName = focused ? "ios-home" : "ios-home-outline";
                } else if (route.name === "Courses") {
                  iconName = focused ? "ios-albums" : "ios-albums-outline";
                } else if (route.name === "Projects") {
                  iconName = focused ? "ios-folder" : "ios-folder-outline";
                }
                return <Ionicons name={iconName} size={26} color={color} />;
              },
              tabBarActiveTintColor: "#4775f2",
              tabBarInactiveTintColor: "#b8bece",
              headerShown: false,
            })}
          >
            <Tab.Screen name="Home" component={HomeScreen} />
            <Tab.Screen name="Courses" component={SectionScreen} />
            <Tab.Screen name="Projects" component={SectionScreen} />
          </Tab.Navigator>
        </NavigationContainer>
      </Provider>
    );
    
    export default App;

相关问题