ReactNative0.44之后不能使用Navigator 谁借莪1个温暖的怀抱¢ 2022-06-03 06:40 150阅读 0赞 在使用react native开发时,使用navigator出现了一个错误。错误提示为: 'Navigator is deprecated and has been removed from this package. It can now be installed ' + 'and imported from `react-native-deprecated-custom-components` instead of `react-native`. ' + 'Learn about alternative navigation solutions at http://facebook.github.io/react-native/docs/navigation.html' 如果出现这个错误,表示当前使用的React Native使用的版本高了。在 **0.44版本**之后就不能使用Navigator。我们可以在reactNative中文文档中看到在0.44之后就不包含了navigator(http://reactnative.cn/)。我们可以在我们的我们项目中pagejson.json中查看我们的版本。 "dependencies": { "react": "16.0.0", "react-native": "0.51.0" }, 解决办法: 1.打开我们的项目文件,例如我的项目时NavigatorValue(在E:\\Project\\ReactNativeProject\\NavigatorValue),打开命令提示窗口,进入到这个目录下。![20171221095623791][] 2.输入下面这个命令npm install --save [https://github.com/facebookarchive/react-native-custom-components.git][https_github.com_facebookarchive_react-native-custom-components.git] (**注意**:我在试过了npm install react-native-deprecated-custom-components --save这个方法。总是报 React-Native – undefined is not an object (“evaluating _react3.default.PropTypes.shape”) 如果你已经安装了,使用(npm uninstall --save react-native-deprecated-custom-components卸载了)。 3.在我们使用Navigator的js文件中加入下面这个导入包就可以了。 import \{ Navigator \} from'react-native-deprecated-custom-components';(注意最后有一个分号) 4.就可以正常使用Navigator组件了。 在备注二中有一个实例可以下载看看试试。 备注: 一、如果使用npm下载失败的话,还有一种办法: 1.在我们项目目录下的pagejson.json文件中,加入下面内容: "dependencies": { "react": "16.0.0", "react-native": "0.51.0", "react-native-deprecated-custom-components": "git+https://github.com/facebookarchive/react-native-custom-components.git" }, 然后下载Navigator额外的包,并放入到**node\_modules文件夹**中。地址是: [http://download.csdn.net/download/cw\_hello1/10167195][http_download.csdn.net_download_cw_hello1_10167195] 这样就可以使用了navigator。在需要使用Navigator的js文件中加入: import \{ Navigator \} from'react-native-deprecated-custom-components';(注意最后有一个分号) 二、一个Navigator的实例: 地址:[http://download.csdn.net/download/cw\_hello1/10167186][http_download.csdn.net_download_cw_hello1_10167186] 如果有什么问题,可以去加3224272023QQ.或者在下面提问。 如果有帮助的话,可以扫一扫。 ![Center][] ![Center 1][] [20171221095623791]: /images/20220603/bd6c808fa95646c59e822551cbdbae0c.png [https_github.com_facebookarchive_react-native-custom-components.git]: https://github.com/facebookarchive/react-native-custom-components.git [http_download.csdn.net_download_cw_hello1_10167195]: http://download.csdn.net/download/cw_hello1/10167195 [http_download.csdn.net_download_cw_hello1_10167186]: http://download.csdn.net/download/cw_hello1/10167186 [Center]: https://img-blog.csdn.net/20171221105216693?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvY3dfaGVsbG8x/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center [Center 1]: /images/20220603/f9174339a1b44108913165336c429b50.png
还没有评论,来说两句吧...