@@ -40,9 +40,17 @@ const AjaxUploader: React.FC<Readonly<React.PropsWithChildren<UploadProps>>> = p
4040 children,
4141 directory,
4242 openFileDialogOnClick,
43+ hasControlInside,
44+ action,
45+ headers,
46+ withCredentials,
47+ method,
4348 onMouseEnter,
4449 onMouseLeave,
45- hasControlInside,
50+ data,
51+ beforeUpload,
52+ onStart,
53+ customRequest,
4654 ...otherProps
4755 } = props ;
4856
@@ -81,7 +89,6 @@ const AjaxUploader: React.FC<Readonly<React.PropsWithChildren<UploadProps>>> = p
8189 * Process file before upload. When all the file is ready, we start upload.
8290 */
8391 const processFile = async ( file : RcFile , fileList : RcFile [ ] ) : Promise < ParsedFileInfo > => {
84- const { beforeUpload } = props ;
8592 let transformedFile : BeforeUploadFileType | void = file ;
8693 if ( beforeUpload ) {
8794 try {
@@ -100,17 +107,13 @@ const AjaxUploader: React.FC<Readonly<React.PropsWithChildren<UploadProps>>> = p
100107 }
101108 }
102109
103- // Get latest action
104- const { action } = props ;
105110 let mergedAction : string ;
106111 if ( typeof action === 'function' ) {
107112 mergedAction = await action ( file ) ;
108113 } else {
109114 mergedAction = action ;
110115 }
111116
112- // Get latest data
113- const { data } = props ;
114117 let mergedData : Record < string , unknown > ;
115118 if ( typeof data === 'function' ) {
116119 mergedData = await data ( file ) ;
@@ -144,19 +147,19 @@ const AjaxUploader: React.FC<Readonly<React.PropsWithChildren<UploadProps>>> = p
144147 } ;
145148 } ;
146149
147- const post = ( { data , origin , action , parsedFile } : ParsedFileInfo ) => {
150+ const post = ( info : ParsedFileInfo ) => {
148151 if ( ! isMountedRef . current ) {
149152 return ;
150153 }
151154
152- const { onStart , customRequest , headers , withCredentials , method } = props ;
155+ const { origin , parsedFile } = info ;
153156
154157 const request = customRequest || defaultRequest ;
155158
156159 const requestOption : UploadRequestOption = {
157- action,
160+ action : info . action ,
158161 filename : name ,
159- data,
162+ data : info . data ,
160163 file : parsedFile ,
161164 headers,
162165 withCredentials,
@@ -266,9 +269,7 @@ const AjaxUploader: React.FC<Readonly<React.PropsWithChildren<UploadProps>>> = p
266269 style = { style }
267270 role = { disabled || hasControlInside ? undefined : 'button' }
268271 tabIndex = { disabled || hasControlInside ? undefined : 0 }
269- className = { classnames ( prefixCls , className , {
270- [ `${ prefixCls } -disabled` ] : disabled ,
271- } ) }
272+ className = { classnames ( prefixCls , className , { [ `${ prefixCls } -disabled` ] : disabled } ) }
272273 >
273274 < input
274275 { ...pickAttrs ( otherProps , { aria : true , data : true } ) }
0 commit comments