作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的 React Native 项目中,我收到以下警告。
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.
Warning: React.createClass is no longer supported. Use a plain JavaScript class instead. If you're not yet ready to migrate, create-react-class is available on npm as a drop-in replacement.
Warning: View.propTypes has been deprecated and will be removed in a future version of ReactNative. Use ViewPropTypes instead.
但是,我很确定我没有在我的项目中执行此操作并且进行了全局搜索,它们的实例似乎位于节点模块文件夹中,特别是在我尚未安装的模块中我。我应该如何进行?我已尝试按照文档中的建议使用以下命令进行重构。
jscodeshift -t react-codemod/transforms/React-PropTypes-to-prop-types.js <path>
当我尝试这样做时,几个节点模块已损坏,并且应用程序无法编译。之后我不得不重新安装 npm 模块,所以我没有取得任何进展。
最佳答案
出现警告是因为 PropTypes 被移至单独的包 - 'prop-types'。此外,React.createClass 已被弃用。
该警告发生在您的应用程序或您使用的包中。
要在您的应用中删除它,请使用
import PropTypes from 'prop-types';
将 React.createClass
转换为 ES6 组件。
如果警告发生在您正在使用的软件包中,请通过提出 git 问题来告知相关软件包所有者。大多数软件包已经进行了此更改。因此,您应该只升级这些软件包。如果包是最新的,并且错误仍然存在,请提出问题。
关于javascript - React Native 警告 - 例如 "PropTypes has been moved to a separate package",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45438123/
我是一名优秀的程序员,十分优秀!