fix: Upload onChange immutable (#22322)

* refactor tree dir

* Upload onChange immutable

* update test case

* fix lint
This commit is contained in:
二货机器人 2020-03-18 00:02:23 +08:00 committed by GitHub
parent 28fea02011
commit 8453cb7b2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -188,7 +188,10 @@ class Upload extends React.Component<UploadProps, UploadState> {
const { onChange } = this.props;
if (onChange) {
onChange(info);
onChange({
...info,
fileList: [...info.fileList],
});
}
};

View File

@ -130,7 +130,9 @@ describe('Upload List', () => {
it('should be uploading when upload a file', done => {
let wrapper;
const onChange = ({ file }) => {
let latestFileList = null;
const onChange = ({ file, fileList: eventFileList }) => {
expect(eventFileList === latestFileList).toBeFalsy();
if (file.status === 'uploading') {
expect(wrapper.render()).toMatchSnapshot();
}
@ -138,6 +140,8 @@ describe('Upload List', () => {
expect(wrapper.render()).toMatchSnapshot();
done();
}
latestFileList = eventFileList;
};
wrapper = mount(
<Upload