2

I am new to react js. We used react-table to display the records in the tabular format. The issue which I am facing is pagination is not working. To enable the pagination in react-table, set the props according to the documentation i.e.

<ReactTable
   manual
   className="expandableTable -highlight"
   columns={this.props.column}
   data={this.state.data}
   showPagination={true}
   minRow={5}
   defaultSortDesc={true}
   ref={this.props.id}
   defaultPageSize={5}
   multiSort={false}
   ...

Any suggestion, what I am missing here?

1 Answer 1

1

Try adding these to you code. and this.props.onFetch is a custom method whenever you will change the page it will go into this.props.onFetch method. i hope this helps.

 onPageChange={(pageIndex) => { // Called when the page index is changed by the user
              this.setState({
                currentPageIndex: pageIndex
              });
              this.props.onFetchPage(this.props.status, pageIndex, this.state.pageSize, this.state.sorted);
            }}

onPageSizeChange={(pageSize, pageIndex) => {
          this.setState({
            pageSize: pageSize
          })
          this.props.onFetchPage(this.props.status, 0, pageSize, this.state.sorted);
        }}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.