【问题标题】:navigator is deprecated and has been removed even i don't use navigatornavigator 已弃用,即使我不使用 navigator 也已被删除
【发布时间】:2017-06-19 17:56:26
【问题描述】:

我的代码中没有使用 Navigator。但是我收到了这个错误。

"dependencies": {
    "react": "16.0.0-alpha.12",
    "react-native": "0.45.1",
    "react-native-deprecated-custom-components": "^0.1.0",
    "react-native-router-redux": "^0.2.2",
    "react-redux": "^5.0.5",
    "redux": "^3.7.0"
},
"devDependencies": {
    "babel-jest": "20.0.3",
    "babel-preset-react-native": "2.0.0",
    "jest": "20.0.4",
    "react-test-renderer": "16.0.0-alpha.12"
}

谁能帮帮我?

【问题讨论】:

  • react-navigation 依赖它吗?看起来react-native-implementation 的第 120 行使用了它。
  • 不,不需要。
  • 那么,我该如何解决呢?
  • 导航器已弃用!其他选项将在此处提及:facebook.github.io/react-native/docs/navigation.html

标签: react-native navigation


【解决方案1】:

当我的 IDE 自动添加以下行时,我发生了这种情况:

import * as AsyncStorage from "react-native";

这意味着:该文件中的所有内容都不起作用。改成这样解决了:

import AsyncStorage from "react-native";

【讨论】:

  • 难以置信!你在这里为我节省了几个小时!
  • 非常感谢。在我的情况下,它是 import * as PropTypes from "react-native";
【解决方案2】:

Navigator 在本机反应中不再支持,因此不再允许这样做:

import { Navigator } from 'react-native'

从“react-native”导入中删除导航器并将其替换为: import { Navigator } from 'react-native-deprecated-custom-components';

【讨论】:

    【解决方案3】:

    导航实验(以前的 Navigator)已从 React Native 中删除并移至单独的包 react-native-deprecated-custom-components。它已被弃用,不推荐。要修复旧代码,您可以执行以下步骤

    1. 安装包react-native-deprecated-custom-components

      npm install react-native-deprecated-custom-components --save

    2. 导入NavigationExperimental(以前Navigator

      import NavigationExperimental from 'react-native-deprecated-custom-comreponents';

    3. Navigator替换为NavigationExperimental.Navigator

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-26
      • 1970-01-01
      • 1970-01-01
      • 2014-04-04
      • 2020-10-30
      • 2017-08-07
      • 2016-05-09
      • 1970-01-01
      相关资源
      最近更新 更多