question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prop onPageChange from CDataTable trigger two times.

See original GitHub issue

Hello, I am new in core ui. I try to use CDataTable and prop onPageChange. When I click other page, the prop onPageChange will trigger two times.

Here is my code

<CDataTable
      items={this.state.consultant}
      fields={fields}
      itemsPerPage={10}
      pagination
      onPageChange={(page) => console.log('Page ', page)}
      loading={true}
/>

Screen Shot 2020-07-01 at 15 00 43

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
gandaraincommented, Jul 1, 2020

Oh oke thank you. But I just found a solution like this.

<CDataTable
     items={this.state.consultant}
     fields={fields}
     itemsPerPage={10}
     loading={this.state.progress === 100 ? false : true}
     responsive={true}
/>
<CPagination
     activePage={this.state.page}
     pages={this.state.totalPage}
     onActivePageChange={(page) => {
         if (page > 0) {
            this.nextPage(page)
         }
     }}
/>
0reactions
dzakiafifcommented, Feb 21, 2022

Oh oke thank you. But I just found a solution like this.

<CDataTable
     items={this.state.consultant}
     fields={fields}
     itemsPerPage={10}
     loading={this.state.progress === 100 ? false : true}
     responsive={true}
/>
<CPagination
     activePage={this.state.page}
     pages={this.state.totalPage}
     onActivePageChange={(page) => {
         if (page > 0) {
            this.nextPage(page)
         }
     }}
/>

hello, i just want ask something. so in this example code, you use cpagination inside datatable or u make an object in props pagination cdatatable?

Read more comments on GitHub >

github_iconTop Results From Across the Web

CDataTable (Core UI React) prop onPageChange trigger 2 ...
Due to source of CDataTable, they use React useState for default behavior. There is still triggers 2 times, but do payload once.
Read more >
DataTable - CoreUI
If prop is not passed columns will be generated automatically based on keys of the first passed item except keys beginning with underscore...
Read more >
Inovua React Data Grid - change pre-built styling, like ellipsis ...
CDataTable (Core UI React) prop onPageChange trigger 2 times · how to map an array of images and use it as inline style...
Read more >
coreui - Bountysource
Created 2 years ago in coreui/coreui-react with 1 comments. ... CDataTable setState onPageChange callback throws "Warning: Cannot update a component while ...
Read more >
BIG-IP 12.1.3.7 Fixes and Known Issues - AskF5
Cumulative fixes from BIG-IP v12.1.2 Hotfix 2 that are included in this ... IKEv1 racoon daemon is not restarted when killed multiple times....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found