问题描述
在 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.43以上的话,Navigator 不能直接从 react-native 里面获取了。
解决方案
1、在终端输入(在项目的根目录下):
npm install react-native-deprecated-custom-components --save
2、在引用的地方中使用:
import {Navigator} from ‘react-native-deprecated-custom-components’