gpt4 book ai didi

javascript - React Native 警告 - 例如 "PropTypes has been moved to a separate package"

转载 作者:行者123 更新时间:2023-12-03 03:44:58 24 4
gpt4 key购买 nike

在我的 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/

24 4 0
文章推荐: javascript - Angular 4 的 JSONP 回调问题
文章推荐: JavaScript - 使用 .map 时将第二个参数传递给 ES6 模板
文章推荐: javascript - 多个