import React from 'react'; import getFileItem from './getFileItem'; const prefixCls = 'ant-upload'; import Animate from 'rc-animate'; export default React.createClass({ getDefaultProps() { return { items: [] }; }, getInitialState() { return { items: this.props.items }; }, componentWillReceiveProps(nextProps) { if ('items' in nextProps) { this.setState({ items: nextProps.items }); } }, handleClose(file) { let items = this.state.items; let removeItem = getFileItem(file, items); if (removeItem) { items.splice(items.indexOf(removeItem), 1); } this.setState({ items: items }); this.props.onRemove(file.file); }, render() { let items = this.state.items; let downloadItem = (file) => { let statusIcon = file.status === 'done' ? : ; let filename = file.url ? {file.filename} : {file.filename}; return (
{statusIcon} {filename}
); }; return (
{items.map(downloadItem)}
); } });