content: import React from 'react';
  import _ from 'lodash';
  import ReactTable from 'react-table';
  
  import 'react-table/react-table.css';
  import './table.less';
  
  class Table extends React.Component {
    constructor(...args) {
      super(...args);
      this.state = {};
    }
  
    render() {
      return (
        <div className={`table-wrapper ${this.props.className}`}>
          <header>
            {
              _.map(this.props.columns, (column, i) => {
                return (
                  <h6 key={i} onClick={this.props.onClickHeader ? this.props.onClickHeader.bind(this, column) : null} className={`column-header ${column.header}`}> {column.header} </h6>
                );
              })
            }
          </header>
  
          <section>
            {
              _.map(this.props.data, (item, i) => {
                return (
                  <div 
                    key={i}
                    className={`table-row ${this.props.onClickRow ? 'clickable' : ''}`}
                    onClick={this.props.onClickRow ? this.props.onClickRow.bind(this, item) : null}>
                    {
                      _.map(this.props.columns, (column, ci) => {
                        const {value, name} = this.accessor(item, ci)
                        return (
                          <h6 key={ci} className={`row-item ${name}`}> {value} </h6>
                        );
                      })
                    }
                  </div>
                );
              })
            }
          </section>
        </div>
      );
    }
  
    accessor(item, i) {
      const {accessor, header} = _.get(this.props.columns, `[${i%this.props.columns.length}]`);
      if (typeof accessor === 'string') {
        return {
          value: _.get(item, `${accessor}`),
          name: header
        }
      } else if (typeof accessor === 'function') {
        return {
          value: accessor(item),
          name: header
        }
      }
    }
  }
  
  Table.propTypes = {};
  
  export default Table;