在使用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'
"dependencies": {
"react": "16.0.0",
"react-native": "0.51.0"
},
1.打开我们的项目文件,例如我的项目时NavigatorValue(在E:\Project\ReactNativeProject\NavigatorValue),打开命令提示窗口,进入到这个目录下。
2.输入下面这个命令npm install --save 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.youkuaiyun.com/download/cw_hello1/10167195
这样就可以使用了navigator。在需要使用Navigator的js文件中加入:
import { Navigator } from'react-native-deprecated-custom-components';(注意最后有一个分号)
二、一个Navigator的实例:
地址:http://download.youkuaiyun.com/download/cw_hello1/10167186
如果有什么问题,可以去加3224272023QQ.或者在下面提问。
如果有帮助的话,可以扫一扫。