@@ -54,7 +54,7 @@ const AjaxUploader: React.FC<Readonly<React.PropsWithChildren<UploadProps>>> = p
5454 ...otherProps
5555 } = props ;
5656
57- const [ uid , setUid ] = React . useState < string > ( getUid ) ;
57+ const [ uid , setUid ] = React . useState < string > ( getUid ( ) ) ;
5858
5959 const isMountedRef = React . useRef < boolean > ( false ) ;
6060 const inputRef = React . useRef < HTMLInputElement > ( null ) ;
@@ -80,8 +80,8 @@ const AjaxUploader: React.FC<Readonly<React.PropsWithChildren<UploadProps>>> = p
8080 React . useEffect ( ( ) => {
8181 isMountedRef . current = true ;
8282 return ( ) => {
83- abort ( ) ;
8483 isMountedRef . current = false ;
84+ abort ( ) ;
8585 } ;
8686 } , [ ] ) ;
8787
@@ -91,10 +91,9 @@ const AjaxUploader: React.FC<Readonly<React.PropsWithChildren<UploadProps>>> = p
9191 const processFile = async ( file : RcFile , fileList : RcFile [ ] ) : Promise < ParsedFileInfo > => {
9292 let transformedFile : BeforeUploadFileType | void = file ;
9393 if ( beforeUpload ) {
94- try {
94+ if ( typeof beforeUpload === 'function' ) {
9595 transformedFile = await beforeUpload ( file , fileList ) ;
96- } catch {
97- // Rejection will also trade as false
96+ } else {
9897 transformedFile = false ;
9998 }
10099 if ( transformedFile === false ) {
@@ -193,11 +192,7 @@ const AjaxUploader: React.FC<Readonly<React.PropsWithChildren<UploadProps>>> = p
193192 props . onBatchStart ?.(
194193 fileList . map ( ( { origin, parsedFile } ) => ( { file : origin , parsedFile } ) ) ,
195194 ) ;
196- fileList
197- . filter ( file => file . parsedFile !== null )
198- . forEach ( file => {
199- post ( file ) ;
200- } ) ;
195+ fileList . filter ( file => file . parsedFile !== null ) . forEach ( file => post ( file ) ) ;
201196 } ) ;
202197 } ;
203198
@@ -217,7 +212,7 @@ const AjaxUploader: React.FC<Readonly<React.PropsWithChildren<UploadProps>>> = p
217212 return ;
218213 }
219214 const target = event . target as HTMLElement ;
220- if ( target ?. tagName === 'BUTTON' ) {
215+ if ( target ?. tagName . toUpperCase ( ) === 'BUTTON' ) {
221216 const parent = inputRef . current . parentNode as HTMLInputElement ;
222217 parent . focus ( ) ;
223218 target . blur ( ) ;
0 commit comments