import React, { useState } from 'react'; import { FileListContainer, UploadedItem, AttachIcon, Progress, ItemName, Close, Spinner } from '../style'; import { useTransition, animated } from 'react-spring'; import theme from 'styles/theme'; export type FileDesc = { isLoading: boolean; isError: boolean; progress: number; data: any; name: string; uid: string; file: File; }; type IProps = { uploaded: FileDesc[]; width: number | string; onRemove: (index: number, isLoading: boolean) => void; }; const FileList = function({ uploaded, width, onRemove }: IProps) { const transitions = useTransition(uploaded, (k: FileDesc) => k.uid + k.isLoading, { from: { height: 0 }, enter: (item: any) => ({ height: item.isLoading ? 48 : 32 }), leave: { height: 0, overflow: 'hidden' }, unique: true, config: { tension: 300, clamp: true, }, } as any); return ( {transitions.map(({ item, props, key }, index) => ( {/*{item.isLoading ? : }*/} {item.name} {item.isLoading && } onRemove(index, item.isLoading)} /> ))} ); }; FileList.defaultProps = { theme, }; export default FileList;