Skip to content

Commit

Permalink
fix: upload circle ref (#34379)
Browse files Browse the repository at this point in the history
Co-authored-by: kanweiwei <kanweiwei@nutstore.net>
  • Loading branch information
kanweiwei and kanweiwei committed Apr 24, 2022
1 parent c1831fb commit 6a08a46
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
22 changes: 2 additions & 20 deletions components/upload/Upload.tsx
Expand Up @@ -2,7 +2,6 @@ import * as React from 'react';
import RcUpload, { UploadProps as RcUploadProps } from 'rc-upload';
import useMergedState from 'rc-util/lib/hooks/useMergedState';
import classNames from 'classnames';
import Dragger from './Dragger';
import UploadList from './UploadList';
import {
RcFile,
Expand All @@ -20,7 +19,7 @@ import defaultLocale from '../locale/default';
import { ConfigContext } from '../config-provider';
import devWarning from '../_util/devWarning';

const LIST_IGNORE = `__LIST_IGNORE_${Date.now()}__`;
export const LIST_IGNORE = `__LIST_IGNORE_${Date.now()}__`;

export { UploadProps };

Expand Down Expand Up @@ -424,24 +423,7 @@ const InternalUpload: React.ForwardRefRenderFunction<unknown, UploadProps> = (pr
);
};

const ForwardUpload = React.forwardRef<unknown, UploadProps>(InternalUpload) as <T>(
props: React.PropsWithChildren<UploadProps<T>> & React.RefAttributes<any>,
) => React.ReactElement;

type InternalUploadType = typeof ForwardUpload;

interface UploadInterface extends InternalUploadType {
defaultProps?: Partial<UploadProps>;
displayName?: string;
Dragger: typeof Dragger;
LIST_IGNORE: string;
}

const Upload = ForwardUpload as UploadInterface;

Upload.Dragger = Dragger;

Upload.LIST_IGNORE = LIST_IGNORE;
const Upload = React.forwardRef<unknown, UploadProps>(InternalUpload);

Upload.displayName = 'Upload';

Expand Down
14 changes: 13 additions & 1 deletion components/upload/index.tsx
@@ -1,8 +1,20 @@
import Upload from './Upload';
import Dragger from './Dragger';
import InternalUpload, { LIST_IGNORE, UploadProps } from './Upload';

export { UploadProps, UploadListProps, UploadChangeParam, RcFile } from './interface';
export { DraggerProps } from './Dragger';

type InternalUploadType = typeof InternalUpload;
interface UploadInterface<T = any> extends InternalUploadType {
<U extends T>(
props: React.PropsWithChildren<UploadProps<U>> & React.RefAttributes<any>,
): React.ReactElement;
Dragger: typeof Dragger;
LIST_IGNORE: string;
}

const Upload = InternalUpload as UploadInterface;
Upload.Dragger = Dragger;
Upload.LIST_IGNORE = LIST_IGNORE;

export default Upload;

0 comments on commit 6a08a46

Please sign in to comment.