React Table Pro (7kb gzip)
Install
npm i react-table-pro
Typing Flow
Use ./flow-typed/react-table-pro.js
.
Typing TypeScript
Use ./@types/index.d.ts
.
Usage example
// @flow;;; ; type ApiResultType = // ApiResultType are equals for TableBodyCellType for example only // you can use your own structure api's data +key: string: string | number | boolean | Node; // your own function to fetch data: Promise<Array<ApiResultType>> { const query = `page=&limit=&sortBy=&order=`; // you should catch api's error here :) return // $FlowFixMe ;} const tableHeader: TableHeaderType = // title of table, string, required title: 'User list' // list of column descriptions, required columnList: // unique field name in ApiResultType, string, required id: 'id' // aling of content, type TableCellAlignType = left | center | right, required align: 'left' // column's name, string, required label: 'Id' // can or can't sort by this field id, boolean, required hasSort: false id: 'isAdmin' align: 'center' label: 'Is admin' hasSort: true id: 'login' align: 'right' label: 'Login' hasSort: true ; : Promise<TableGetDataResultType> { const dataList: Array<ApiResultType> = await ; return // all elements number, number, required count: 50 // Array of table cell data, Array<TableBodyCellType>, required list: dataList ;} : Node { return <Table // function to get data, type TableGetDataType, required getData=tableGetUserList // table header data, type TableHeaderType, required header=tableHeader /> ;}