在新版的RN中,因为Navigator
已经不再react-native
这个库中了,如果继续从该库中导入,系统会直接给我们抛出一个错误,如下图:
提示我们Navigator
已经过期,我们可以从react-native-deprecated-custom-components
库中导入.
根据提示我们执行:
npm install react-native-deprecated-custom-components --save
然后在项目中我们直接导入Navigator
:
import {Navigator} from 'react-native-deprecated-custom-components'
但是一运行之后系统仍然给我抛了一个错误:
React-Native – undefined is not an object (“evaluating _react3.default.PropTypes.shape”)]
解决方法:从stackoverflow找到了一种解决方法,这里贴出来方便以后查看:
it seems like they haven't updated their npm package but their github branch has the proptypes changes,
Uninstall the already installed react-native-deprecated-custom-components like below.
npm uninstall --save react-native-deprecated-custom-components
After that install it as follows.
npm install --save https://github.com/facebookarchive/react-native-custom-components.git
网友评论