From 7502d84d154dfd1def9ce5e5fc686a36a90e2365 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 7 Aug 2020 17:14:55 +0800 Subject: [PATCH] docs: fix demo typo --- components/upload/demo/upload-png-only.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/upload/demo/upload-png-only.md b/components/upload/demo/upload-png-only.md index 70f4d5bef0..80c6d76975 100644 --- a/components/upload/demo/upload-png-only.md +++ b/components/upload/demo/upload-png-only.md @@ -7,11 +7,11 @@ title: ## zh-CN -`beforeUpload` 返回 `false` 或 `Promise.reject` 时,只用于拦截上传行为,不会阻止文件进入上传列表([原因](https://github.com/ant-design/ant-design/issues/15561#issuecomment-475108235)。如果需要阻止列表展现,可以参照此例配合 `onChange` 进行实现。 +`beforeUpload` 返回 `false` 或 `Promise.reject` 时,只用于拦截上传行为,不会阻止文件进入上传列表([原因](https://github.com/ant-design/ant-design/issues/15561#issuecomment-475108235))。如果需要阻止列表展现,可以参照此例配合 `onChange` 进行实现。 ## en-US -`beforeUpload` only prevent upload behavior when return false or reject promise, the prevented file would still show in file list. Here is the example you can keep prevented files out of list by using `onChange`. +`beforeUpload` only prevent upload behavior when return false or reject promise, the prevented file would still show in file list. Here is the example you can keep prevented files out of list by using `onChange`. ```jsx import React, { useState } from 'react'; @@ -22,13 +22,13 @@ const Uploader = () => { const [fileList, updateFileList] = useState([]); const props = { fileList, - beforeUpload: (file) => { + beforeUpload: file => { if (file.type !== 'image/png') { message.error(`${file.name} is not a png file`); } return file.type === 'image/png'; }, - onChange: (info) => { + onChange: info => { console.log(info.fileList); // file.status is empty when beforeUpload return false updateFileList(info.fileList.filter(file => !!file.status)); @@ -40,7 +40,7 @@ const Uploader = () => { Upload png only - ) + ); }; ReactDOM.render(, mountNode);