fix(upload): file in fileList should get uid at first (#30087)

* docs: delete info log in tree examples

* fix: make check-ts-demo work

* fix(upload): fileList should add uid at first

* revert(docs): revert delete log(info)

* style: delete unused test utils
This commit is contained in:
wangao 2021-04-13 09:49:58 +08:00 committed by GitHub
parent bbbb7f573c
commit e4e5cc66e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View File

@ -73,7 +73,7 @@ const InternalUpload: React.ForwardRefRenderFunction<unknown, UploadProps> = (pr
}, []);
// Control mode will auto fill file uid if not provided
React.useEffect(() => {
React.useMemo(() => {
const timestamp = Date.now();
(fileList || []).forEach((file, index) => {

View File

@ -1,6 +1,6 @@
/* eslint-disable react/no-string-refs, react/prefer-es6-class */
import React from 'react';
import { mount } from 'enzyme';
import { mount, render } from 'enzyme';
import { act } from 'react-dom/test-utils';
import produce from 'immer';
import { cloneDeep } from 'lodash';
@ -285,6 +285,20 @@ describe('Upload', () => {
jest.useRealTimers();
});
it('should be able to get uid at first', () => {
const fileList = [
{
name: 'foo.png',
status: 'done',
url: 'http://www.baidu.com/xxx.png',
},
];
render(<Upload fileList={fileList} />);
fileList.forEach(file => {
expect(file.uid).toBeDefined();
});
});
describe('util', () => {
it('should be able to get fileItem', () => {
const file = { uid: '-1', name: 'item.jpg' };