Ant 设计:警告:[antd: Upload] `transformFile` 已弃用请直接使用`beforeUpload` :ReactJs

问题描述

我正在使用 react ja 来构建应用程序。为了构建它,我使用了 Ant Design 库。在 Ant Design 中,我使用了 Upload(link) 组件。

组件如下所示:

<Upload
        name="file"
        listType="picture-card"
        className="avatar-uploader"
        showUploadList={true}
        action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
        onChange={this.handleChange}
      >
        {imageUrl ? <img src={imageUrl} alt="avatar" style={{ width: '100%' }} /> : uploadButton}
</Upload>

在开发模式下运行应用程序

Warning: [antd: Upload] `transformFile` is deprecated. Please use `beforeUpload` directly.
warning @ warning.js:6

问题:为什么即使我不在组件中使用 transformFile 也会出现此警告?
另外我不想使用beforeUpload,我为什么要强制使用它?谁遇到过同样的问题?

解决方法

您必须将 Antd 版本升级到“4.12.3”

,

该警告已从 v4.10.0 中删除。

https://github.com/ant-design/ant-design/releases/tag/4.10.0