Skip to content

Commit

Permalink
docs: Upload demo add import React statement
Browse files Browse the repository at this point in the history
  • Loading branch information
madocto committed Mar 28, 2022
1 parent b86bce7 commit 0b450f0
Show file tree
Hide file tree
Showing 19 changed files with 24 additions and 9 deletions.
5 changes: 3 additions & 2 deletions components/upload/demo/avatar.md
Expand Up @@ -18,6 +18,7 @@ Click to upload user's avatar, and validate size and format of picture with `bef
> The return value of function `beforeUpload` can be a Promise to check asynchronously. [demo](https://upload-react-component.vercel.app/demo/before-upload#beforeupload)
```tsx
import React, { useState } from 'react';
import { Upload, message } from 'antd';
import { LoadingOutlined, PlusOutlined } from '@ant-design/icons';
import type { UploadChangeParam } from 'antd/es/upload';
Expand All @@ -42,8 +43,8 @@ const beforeUpload = (file: RcFile) => {
};

const App = () => {
const [loading, setLoading] = React.useState(false);
const [imageUrl, setImageUrl] = React.useState<string>();
const [loading, setLoading] = useState(false);
const [imageUrl, setImageUrl] = useState<string>();

const handleChange: UploadProps['onChange'] = (info: UploadChangeParam<UploadFile>) => {
if (info.file.status === 'uploading') {
Expand Down
1 change: 1 addition & 0 deletions components/upload/demo/basic.md
Expand Up @@ -14,6 +14,7 @@ title:
Classic mode. File selection dialog pops up when upload button is clicked.

```tsx
import React from 'react';
import { Upload, message, Button } from 'antd';
import { UploadOutlined } from '@ant-design/icons';
import type { UploadProps } from 'antd';
Expand Down
3 changes: 2 additions & 1 deletion components/upload/demo/crop-image.md
Expand Up @@ -14,12 +14,13 @@ title:
Use [antd-img-crop](https://github.com/nanxiaobei/antd-img-crop) to crop image before uploading.

```tsx
import React, { useState } from 'react';
import { Upload } from 'antd';
import ImgCrop from 'antd-img-crop';
import type { RcFile, UploadFile, UploadProps } from 'antd/es/upload/interface';

const App = () => {
const [fileList, setFileList] = React.useState<UploadFile[]>([
const [fileList, setFileList] = useState<UploadFile[]>([
{
uid: '-1',
name: 'image.png',
Expand Down
1 change: 1 addition & 0 deletions components/upload/demo/customize-progress-bar.md
Expand Up @@ -14,6 +14,7 @@ title:
Use `progress` for customize progress bar.

```tsx
import React from 'react';
import { Upload, message, Button } from 'antd';
import { UploadOutlined } from '@ant-design/icons';
import type { UploadProps } from 'antd';
Expand Down
1 change: 1 addition & 0 deletions components/upload/demo/defaultFileList.md
Expand Up @@ -14,6 +14,7 @@ title:
Use `defaultFileList` for uploaded files when page init.

```tsx
import React from 'react';
import { Upload, Button } from 'antd';
import { UploadOutlined } from '@ant-design/icons';
import type { UploadProps } from 'antd';
Expand Down
1 change: 1 addition & 0 deletions components/upload/demo/directory.md
Expand Up @@ -14,6 +14,7 @@ title:
You can select and upload a whole directory.

```tsx
import React from 'react';
import { Upload, Button } from 'antd';
import { UploadOutlined } from '@ant-design/icons';

Expand Down
2 changes: 1 addition & 1 deletion components/upload/demo/drag-sorting.md
Expand Up @@ -14,7 +14,7 @@ title:
By using `itemRender`, we can integrate upload with react-dnd to implement drag sorting of uploadList.

```tsx
import { useState, useCallback, useRef } from 'react';
import React, { useState, useCallback, useRef } from 'react';
import { Upload, Button, Tooltip } from 'antd';
import { DndProvider, useDrag, useDrop } from 'react-dnd';
import { HTML5Backend } from 'react-dnd-html5-backend';
Expand Down
1 change: 1 addition & 0 deletions components/upload/demo/drag.md
Expand Up @@ -18,6 +18,7 @@ You can drag files to a specific area, to upload. Alternatively, you can also up
We can upload serveral files at once in modern browsers by giving the input the `multiple` attribute.

```tsx
import React from 'react';
import { Upload, message } from 'antd';
import { InboxOutlined } from '@ant-design/icons';
import type { UploadProps } from 'antd';
Expand Down
2 changes: 1 addition & 1 deletion components/upload/demo/file-type.md
Expand Up @@ -15,7 +15,7 @@ title:
Displays the corresponding by default by type icon

```tsx
import { useState } from 'react';
import React, { useState } from 'react';
import { Upload, Modal } from 'antd';
import {
LoadingOutlined,
Expand Down
3 changes: 2 additions & 1 deletion components/upload/demo/fileList.md
Expand Up @@ -22,13 +22,14 @@ You can gain full control over filelist by configuring `fileList`. You can accom
2. read from response and show file link.

```tsx
import React, { useState } from 'react';
import { Upload, Button } from 'antd';
import { UploadOutlined } from '@ant-design/icons';
import type { UploadFile } from 'antd/es/upload/interface';
import type { UploadProps } from 'antd';

const App = () => {
const [fileList, setFileList] = React.useState<UploadFile[]>([
const [fileList, setFileList] = useState<UploadFile[]>([
{
uid: '-1',
name: 'xxx.png',
Expand Down
1 change: 1 addition & 0 deletions components/upload/demo/max-count.md
Expand Up @@ -14,6 +14,7 @@ title:
Limit files with `maxCount`. Will replace current one when `maxCount` is `1`.

```tsx
import React from 'react';
import { Upload, Button, Space } from 'antd';
import { UploadOutlined } from '@ant-design/icons';

Expand Down
2 changes: 1 addition & 1 deletion components/upload/demo/picture-card.md
Expand Up @@ -14,7 +14,7 @@ title:
After users upload picture, the thumbnail will be shown in list. The upload button will disappear when count meets limitation.

```tsx
import { useState } from 'react';
import React, { useState } from 'react';
import { Upload, Modal } from 'antd';
import { PlusOutlined } from '@ant-design/icons';
import type { UploadFile } from 'antd/es/upload/interface';
Expand Down
1 change: 1 addition & 0 deletions components/upload/demo/picture-style.md
Expand Up @@ -14,6 +14,7 @@ title:
If uploaded file is a picture, the thumbnail can be shown. `IE8/9` do not support local thumbnail show. Please use `thumbUrl` instead.

```tsx
import React from 'react';
import { Upload, Button } from 'antd';
import { UploadOutlined } from '@ant-design/icons';
import type { UploadFile } from 'antd/es/upload/interface';
Expand Down
1 change: 1 addition & 0 deletions components/upload/demo/preview-file.md
Expand Up @@ -14,6 +14,7 @@ title:
Customize local preview. Can handle with non-image format files such as video.

```tsx
import React from 'react';
import { Upload, Button } from 'antd';
import { UploadOutlined } from '@ant-design/icons';
import type { UploadProps } from 'antd';
Expand Down
1 change: 1 addition & 0 deletions components/upload/demo/transform-file.md
Expand Up @@ -14,6 +14,7 @@ title:
Use `beforeUpload` for transform file before request such as add a watermark.

```tsx
import React from 'react';
import { Upload, Button } from 'antd';
import { UploadOutlined } from '@ant-design/icons';
import type { UploadProps } from 'antd';
Expand Down
1 change: 1 addition & 0 deletions components/upload/demo/upload-custom-action-icon.md
Expand Up @@ -14,6 +14,7 @@ title:
Use `showUploadList` for custom action icons of files.

```tsx
import React from 'react';
import { Upload, Button } from 'antd';
import { UploadOutlined, StarOutlined } from '@ant-design/icons';
import type { UploadProps } from 'antd';
Expand Down
2 changes: 1 addition & 1 deletion components/upload/demo/upload-manually.md
Expand Up @@ -14,7 +14,7 @@ title:
Upload files manually after `beforeUpload` returns `false`.

```tsx
import { useState } from 'react';
import React, { useState } from 'react';
import { Upload, Button, message } from 'antd';
import { UploadOutlined } from '@ant-design/icons';
import type { RcFile, UploadFile, UploadProps } from 'antd/es/upload/interface';
Expand Down
1 change: 1 addition & 0 deletions components/upload/demo/upload-png-only.md
Expand Up @@ -14,6 +14,7 @@ title:
`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 return `UPLOAD.LIST_IGNORE`.

```tsx
import React from 'react';
import { Upload, Button, message } from 'antd';
import { UploadOutlined } from '@ant-design/icons';
import type { UploadProps } from 'antd';
Expand Down
3 changes: 2 additions & 1 deletion components/upload/demo/upload-with-aliyun-oss.md
Expand Up @@ -14,6 +14,7 @@ title:
Use Aliyun OSS upload example.

```tsx
import React, { useState } from 'react';
import { Form, Upload, message, Button } from 'antd';
import { UploadOutlined } from '@ant-design/icons';
import type { UploadProps } from 'antd';
Expand All @@ -34,7 +35,7 @@ interface AliyunOSSUploadProps {
}

const AliyunOSSUpload = ({ value, onChange }: AliyunOSSUploadProps) => {
const [OSSData, setOSSData] = React.useState<OSSDataType>();
const [OSSData, setOSSData] = useState<OSSDataType>();

// Mock get OSS api
// https://help.aliyun.com/document_detail/31988.html
Expand Down

0 comments on commit 0b450f0

Please sign in to comment.