项目作者: garrylachman

项目描述 :
React-Native Simple Data Tables
高级语言: TypeScript
项目地址: git://github.com/garrylachman/react-native-awesome-table.git
创建时间: 2021-06-09T23:42:59Z
项目社区:https://github.com/garrylachman/react-native-awesome-table

开源协议:MIT License

下载


react-native-awesome-table

React-Native Simple Data Tables

Examples cam be found on our Storybook https://garrylachman.github.io/react-native-awesome-table/?path=/story/cell--default

Installation

NPM

  1. npm -i --save react-native-awesome-table

YARN

  1. yarn add react-native-awesome-table

Examples

Basic Example

Basic Example

  1. import React from 'react';
  2. import Table, {ColumnProps} from 'react-native-awesome-table';
  3. type DataRow = {
  4. id: number,
  5. firstName: string,
  6. lastName: string,
  7. country: string
  8. };
  9. const columns:ColumnProps[] = [
  10. { 'dataKey': 'id', title: 'ID', flex: 1 },
  11. { 'dataKey': 'firstName', title: 'First Name', flex: 2 },
  12. { 'dataKey': 'lastName', title: 'Last Name', flex: 2 },
  13. { 'dataKey': 'country', title: 'Country', flex: 3 }
  14. ]
  15. const exampleRow:DataRow = {
  16. id: 0,
  17. firstName: "Garry",
  18. lastName: "Lachman",
  19. country: "Israel"
  20. };
  21. export BasicTable = () => {
  22. const [data, setData] = React.useState<DataRow[]>([]);
  23. React.useEffect(() => {
  24. setData(
  25. [...Array(10)].map(
  26. (_, i) => ({...exampleRow, id: ++i})
  27. )
  28. );
  29. }, []);
  30. return (
  31. <Table
  32. columns={columns}
  33. data={data}
  34. ></Table>
  35. )
  36. };

Basic example storybook: https://garrylachman.github.io/react-native-awesome-table/?path=/story/table--basic&args=rowsCount:10

License

React Native Awesome Table is MIT licensed.