fix: should trigger onChange before beforeUpload

This commit is contained in:
niko 2017-09-29 16:52:16 +08:00 committed by Benjy Cui
parent 47e3cedf86
commit 9dc4102cdd

View File

@ -218,6 +218,17 @@ export default class Upload extends React.Component<UploadProps, any> {
}); });
} }
beforeUpload = (file, fileList) => {
if (this.props.beforeUpload && !this.props.beforeUpload(file, fileList)) {
this.onChange({
file,
fileList,
});
return false;
}
return true;
}
clearProgressTimer() { clearProgressTimer() {
clearInterval(this.progressTimer); clearInterval(this.progressTimer);
} }
@ -234,6 +245,7 @@ export default class Upload extends React.Component<UploadProps, any> {
onProgress: this.onProgress, onProgress: this.onProgress,
onSuccess: this.onSuccess, onSuccess: this.onSuccess,
...this.props, ...this.props,
beforeUpload: this.beforeUpload,
}; };
delete rcUploadProps.className; delete rcUploadProps.className;