React Native PropTypes 已移至单独的包 [英] React Native PropTypes has been moved to a separate package
问题描述
我正在使用
react-native-cli 2.0.1
反应原生 0.47.1
反应 16.0.0-beta.2
我完全是 react-native 的初学者,我决定尝试一下这篇文章中由 Denislav Ganchev 编写的 Employee 应用程序
我看到上面截图中错误中的链接指向迁移,但作为一个完整的初学者,我很难弄清楚我需要做什么.
这基本上意味着您需要单独安装该模块,尽管它在以前的版本中是 React 核心模块的一部分.
npm install --save prop-types从 'prop-types' 导入 PropTypes;
更多信息这里
//直到 15.4import React, { PropTypes } from 'react';...React.PropTypes.string.isRequired//现在从反应"导入反应;从 'prop-types' 导入 PropTypes;...PropTypes.string.isRequired
I am using
react-native-cli 2.0.1
react-native 0.47.1
react 16.0.0-beta.2
I am a total beginner in react-native and I decided to give it a try to Employee app written by Denislav Ganchev from this article https://mentormate.com/blog/react-native-components/.
But I am getting this error
Warning: PropTypes has been moved to a separate package. Accessing React.PropTypes is no longer supported and will be removed completely in React 16. Use the prop-types package on npm instead.
Here is the screenshot of the same error
I see the link in the error in screenshot above pointing to migration but as a complete beginner, I have difficult time figuring what I need to do.
It basically means you need to install the module separately, although it was part of React core module in previous versions.
npm install --save prop-types
import PropTypes from 'prop-types';
more info here
// Until 15.4
import React, { PropTypes } from 'react';
...
React.PropTypes.string.isRequired
// Now
import React from 'react';
import PropTypes from 'prop-types';
...
PropTypes.string.isRequired
这篇关于React Native PropTypes 已移至单独的包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!