Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix warning of transformFile prop for upload #28455

Merged
merged 1 commit into from
Dec 21, 2020

Conversation

YanYuanFE
Copy link
Contributor

@YanYuanFE YanYuanFE commented Dec 21, 2020

[中文版模板 / Chinese template]

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • Component style update
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Internationalization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

🔗 Related issue link

<Upload
              name="avatar"
              listType="picture-card"
              className={styles.testUploader}
              style={{ width: '100%' }}
              showUploadList={false}
              beforeUpload={(file) => {
                console.log(file);
                const isJpg = file.type === 'image/jpeg';
                if (!isJpg) {
                  message.error('只能上传JPG格式的图片!');
                } else {
                  getBase64(file, (url) => {
                    const img = new Image();
                    img.src = url;
                    img.onload = () => {
                      console.log(img.width, img.height);
                      setSize([img.width, img.height]);
                    };
                    setUrl(url);
                    setFiles(file);
                  });
                }
                return false;
              }}
            >
              {imgUrl ? <img src={imgUrl} alt="avatar" style={{ width: '100%' }} /> : uploadButton}
            </Upload>

💡 Background and solution

Upload组件报warning
close #28454

📝 Changelog

Language Changelog
🇺🇸 English Fix Upload unexpeced warning.
🇨🇳 Chinese 修复 Upload 预期外的警告问题。

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

@ant-design-bot
Copy link
Contributor

ant-design-bot commented Dec 21, 2020

@codesandbox-ci
Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 6418115:

Sandbox Source
antd reproduction template Configuration

@codecov
Copy link

codecov bot commented Dec 21, 2020

Codecov Report

Merging #28455 (6418115) into master (880664e) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##            master    #28455   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          393       393           
  Lines         7375      7375           
  Branches      2121      2121           
=========================================
  Hits          7375      7375           
Impacted Files Coverage Δ
components/upload/Upload.tsx 100.00% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 880664e...6418115. Read the comment docs.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 21, 2020

Size Change: +10 B (0%)

Total Size: 789 kB

Filename Size Change
./dist/antd-with-locales.min.js 313 kB +5 B (0%)
./dist/antd.min.js 275 kB +5 B (0%)
ℹ️ View Unchanged
Filename Size Change
./dist/antd.compact.min.css 66.7 kB 0 B
./dist/antd.dark.min.css 68 kB 0 B
./dist/antd.min.css 66.7 kB 0 B

compressed-size-action

@afc163
Copy link
Member

afc163 commented Dec 21, 2020

#28454 (comment)

@afc163 afc163 closed this Dec 21, 2020
@YanYuanFE
Copy link
Contributor Author

@afc163 麻烦仔细看下呢,devWarning条件判断错了

@afc163 afc163 reopened this Dec 21, 2020
@afc163 afc163 merged commit 0721ef3 into ant-design:master Dec 21, 2020
@yoyo837 yoyo837 mentioned this pull request Dec 22, 2020
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warning: [antd: Upload] transformFile is deprecated. Please use beforeUpload directly.
3 participants