React Native PropTypes 已移至单独的包 [英] React Native PropTypes has been moved to a separate package

查看:33
本文介绍了React Native PropTypes 已移至单独的包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆