0.0.2 • Published 4 years ago

infinitywrapper v0.0.2

Weekly downloads
6
License
MIT
Repository
github
Last release
4 years ago

React InfinityWrapper HOC

Infinity scroll on ant table or root node

Use this Component

yarn add infinitywrapper to install the latest version

InfinityTable used with ant table

const TableWrapper = ({ bordered, dataSource, scrollable }) => {

  const columns = {
    // columns
  }

  return (
    <Table
      bordered={bordered}
      columns={columns}
      dataSource={dataSource}
      scroll={scrollable ? { y: ROWS_ON_PER_PAGE * ROW_HEIGHT } : {}}
    />
  )
}
export default InfinityWrapper(TableWrapper)
    <InfinityTable
      dataSource={dataSource}
      hasNextPage={hasNextPage}
      rowPerPage={rowPerPage}
      bordered={bordered}
      loadMore={loadMore}
    />

InfinityTable used with whatever

const Wrapper = ({ dataSource }) => {
  return (
    <div>
      {dataSource.map((data) => {
        return <div>{data}</div>
      })}
    </div>
  )
}
export default InfinityWrapper(Wrapper)
    <InfinityTable
      dataSource={dataSource}
      hasNextPage={hasNextPage}
      rowPerPage={rowPerPage}
      loadMore={loadMore}
      isTable={false}
    />

Props

NameTypeDefaultDescription
dataSourceT[]requireddata displayed on page/table
hasNextPagebooleanrequiredIf there is next page
rowPerPagenumberundefinedrow lines displayed per page (only for table)
loadMore()=>voidrequiredWhen scroll down will invoke loadMore function
isTablebooleantrueA flag detect whether is used for ant table

Contribute to this repo

To install dependencies

$ yarn

To build

$ yarn build

To run tests

$ yarn test

To run Storybook

$ yarn start