fix: upload circle ref (#34379)

Co-authored-by: kanweiwei <kanweiwei@nutstore.net>
This commit is contained in:
Camol 2022-04-24 20:55:18 +08:00 committed by GitHub
parent c1831fbf82
commit 6a08a46ecc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 21 deletions

View File

@ -2,7 +2,6 @@ import * as React from 'react';
import RcUpload, { UploadProps as RcUploadProps } from 'rc-upload'; import RcUpload, { UploadProps as RcUploadProps } from 'rc-upload';
import useMergedState from 'rc-util/lib/hooks/useMergedState'; import useMergedState from 'rc-util/lib/hooks/useMergedState';
import classNames from 'classnames'; import classNames from 'classnames';
import Dragger from './Dragger';
import UploadList from './UploadList'; import UploadList from './UploadList';
import { import {
RcFile, RcFile,
@ -20,7 +19,7 @@ import defaultLocale from '../locale/default';
import { ConfigContext } from '../config-provider'; import { ConfigContext } from '../config-provider';
import devWarning from '../_util/devWarning'; import devWarning from '../_util/devWarning';
const LIST_IGNORE = `__LIST_IGNORE_${Date.now()}__`; export const LIST_IGNORE = `__LIST_IGNORE_${Date.now()}__`;
export { UploadProps }; export { UploadProps };
@ -424,24 +423,7 @@ const InternalUpload: React.ForwardRefRenderFunction<unknown, UploadProps> = (pr
); );
}; };
const ForwardUpload = React.forwardRef<unknown, UploadProps>(InternalUpload) as <T>( const Upload = React.forwardRef<unknown, UploadProps>(InternalUpload);
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;
Upload.displayName = 'Upload'; Upload.displayName = 'Upload';

View File

@ -1,8 +1,20 @@
import Upload from './Upload';
import Dragger from './Dragger'; import Dragger from './Dragger';
import InternalUpload, { LIST_IGNORE, UploadProps } from './Upload';
export { UploadProps, UploadListProps, UploadChangeParam, RcFile } from './interface'; export { UploadProps, UploadListProps, UploadChangeParam, RcFile } from './interface';
export { DraggerProps } from './Dragger'; 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.Dragger = Dragger;
Upload.LIST_IGNORE = LIST_IGNORE;
export default Upload; export default Upload;