diff --git a/src/packages/uploader/uploader.taro.tsx b/src/packages/uploader/uploader.taro.tsx index eebd77b238..92c5972929 100644 --- a/src/packages/uploader/uploader.taro.tsx +++ b/src/packages/uploader/uploader.taro.tsx @@ -227,8 +227,7 @@ const InternalUploader: ForwardRefRenderFunction< setUploadQueue(uploadQueue) } else { setUploadQueue([]) - fileList.splice(0, fileList.length) - setFileList([...fileList]) + setFileList([]) } } @@ -425,8 +424,7 @@ const InternalUploader: ForwardRefRenderFunction< if (preview) { fileItem.url = fileType === 'video' ? file.thumbTempFilePath : filepath } - fileList.push(fileItem) - setFileList(fileList) + setFileList([...fileList, fileItem]) executeUpload(fileItem, index) }) } diff --git a/src/packages/uploader/uploader.tsx b/src/packages/uploader/uploader.tsx index 3f4a04ce3a..db7d573f27 100644 --- a/src/packages/uploader/uploader.tsx +++ b/src/packages/uploader/uploader.tsx @@ -173,8 +173,7 @@ const InternalUploader: ForwardRefRenderFunction< setUploadQueue(uploadQueue) } else { setUploadQueue([]) - fileList.splice(0, fileList.length) - setFileList([...fileList]) + setFileList([]) } } @@ -301,13 +300,11 @@ const InternalUploader: ForwardRefRenderFunction< const reader = new FileReader() reader.onload = (event: ProgressEvent) => { fileItem.url = (event.target as FileReader).result as string - fileList.push(fileItem) - setFileList([...fileList]) + setFileList([...fileList, fileItem]) } reader.readAsDataURL(file) } else { - fileList.push(fileItem) - setFileList([...fileList]) + setFileList([...fileList, fileItem]) } }) }