/**
 * Created by baoyinghai on 4/24/17.
 */
import React from 'react';
import { iconWrapper } from '../../../framework/utils/IconHelper';

export default class Tag extends React.Component {

  constructor(props) {
    super(props);
    this.state = {
      isRender: true
    };
  }
  _onClose = event => {
    event.preventDefault();
    const { callback, id } = this.props;
    this.setState({
      isRender: false
    }, () => {
      callback && callback(id);
    });
  };

  render() {
    return this.state.isRender && (
      <div className="tag-wrapper">
        <span>{this.props.children}</span>
        {iconWrapper('icon-guanbifuzhi', undefined, undefined, { onClick: this._onClose })}
      </div>
    );
  }
}
