Cannot use pageListRenderer with PaginationListStandalone
See original GitHub issueI would like to use a custom page list as a standalone component so that I can change the order of the pagination list and total.
However, when I use a custom page list, while it does appear to pass my pageListRenderer in the props, the custom page list is not rendered when used as a standalone component. Instead, the table renders the default page list.
Here are some code snippets.
As a side note, I have my pageListRender in a separate file for re-use in other places. I have tried using it within the same file as the table, but this doesn’t have any impact.
PageListRenderer.js: (nothing fancy here, just copying and pasting the example from Storybook to illustrate the issue)
const PageListRenderer = ({ pages, onPageChange }) => {
const pageWithoutIndication = pages.filter(p => typeof p.page !== "string");
return (
<div>
{pageWithoutIndication.map(p => (
<button
className="btn btn-success"
onClick={() => onPageChange(p.page)}
>
{p.page}
</button>
))}
</div>
);
};
export default PageListRenderer;
SampleTable.js:
import BootstrapTable from "react-bootstrap-table-next";
import paginationFactory, {
PaginationProvider,
PaginationTotalStandalone,
PaginationListStandalone
} from "react-bootstrap-table2-paginator";
import PageListRenderer from "./PageListRenderer";
import { rows, columns } from "../data/data.js";
class SampleTable extends PureComponent {
render() {
const options = {
sizePerPage: 1,
pageListRenderer: props => PageListRenderer({ ...props }),
custom: true,
totalSize: rows && rows.length
};
const pagination = paginationFactory(options);
return (
<PaginationProvider pagination={pagination}>
{({ paginationProps, paginationTableProps }) => (
<div>
<PaginationTotalStandalone {...paginationProps} />
<BootstrapTable
keyField="id"
data={rows}
columns={columns}
{...paginationTableProps}
/>
<PaginationListStandalone {...paginationProps} />
</div>
)}
</PaginationProvider>
);
}
}
export default SampleTable;
App.js:
import "./App.css";
import SampleTable from "./components/SampleTable.js";
function App() {
return (
<div className="container">
<SampleTable />
</div>
);
}
export default App;
Expected:

Actual:

Thanks for your time!
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
Pagination Props · react-bootstrap-table2 - GitHub Pages
Use pagination.page specify the current page when table render. It's necessary value when remote pagination is enabled. pagination.sizePerPage ...
Read more >and previous page not working in react-bootstrap-table2- ...
I have implemented table with pagination using react-bootstrap-table2-paginator. on each pagenumber click it will call api and fetch table ...
Read more >react-bootstrap-table2-paginator-esm
Start using react-bootstrap-table2-paginator-esm in your project by running `npm i ... There are no other projects in the npm registry using ...
Read more >React bootstrap table pagination
You can't perform that action at this time. ... Standalone Pagination List Standalone Pagination Total Standalone When render each standalone, you just need ......
Read more >react-bootstrap-table2-paginator examples
Learn how to use react-bootstrap-table2-paginator by viewing and forking react-bootstrap-table2-paginator example apps on CodeSandbox.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@vhbert I ended up creating my own component replacing the
<PageListRenderer>following the code in the library. I’ll just make a code dump and hopefully you can replicate it in a way you want 😃Here is the component
which I then use like this:
Thanks for the very quick answer, your solution works like a charm. I’ll just have to write some more typings for it since I am using TypeScript.
Thanks again for your help