import React, { useState, useEffect, useCallback } from 'react'
import { Table } from 'antd'
import { useActions, useData, useCommit } from '@ttk/app-loader'

export default function Com(props) {
  const commit = useCommit()
  const actions = useActions(props)
  const treeData = useData([props, 'treeData']).toJS()

  useEffect(() => {
    actions.getTreeData() // 获取数据
  })

  const columns = [
    {
      title: '名称',
      dataIndex: 'name',
      key: 'name',
    },
    {
      title: '年龄',
      width: 100,
      dataIndex: 'age',
      key: 'age',
    },
    { title: '列1', dataIndex: 'address', key: '1', width: 150 },
    { title: '列2', dataIndex: 'address', key: '2', width: 150 },
    {
      title: '操作',
      key: 'operation',
      width: 100,
      render: () => <a>编辑</a>,
    },
  ];

  return (
    <React.Fragment>
      <Table columns={columns} dataSource={treeData} bordered />
    </React.Fragment>
  )
}


