T
TanStack3y ago
rival-black

Pagination - how to start pageIndex from 1 not 0?

My initalPagination is
const [{ pageIndex, pageSize }, setPagination] =
React.useState<PaginationState>({
pageIndex: 1,
pageSize: 10,
});
const [{ pageIndex, pageSize }, setPagination] =
React.useState<PaginationState>({
pageIndex: 1,
pageSize: 10,
});
but when I open a select menu with pageSize values and select e.g. 20
<select
value={table.getState().pagination.pageSize}
onChange={(e) => {
table.setPageSize(Number(e.target.value));
}}
>
{[10, 20, 30, 40, 50].map((pageSize) => (
<option key={pageSize} value={pageSize}>
Show {pageSize}
</option>
))}
</select>
<select
value={table.getState().pagination.pageSize}
onChange={(e) => {
table.setPageSize(Number(e.target.value));
}}
>
{[10, 20, 30, 40, 50].map((pageSize) => (
<option key={pageSize} value={pageSize}>
Show {pageSize}
</option>
))}
</select>
the pageIndex is 0. How to set the pageIndex to start from 1 not from 0? https://codesandbox.io/p/sandbox/sweet-darkness-md8pvc?welcome=true&file=README.md
sweet-darkness-md8pvc
CodeSandbox is an online editor tailored for web applications.
No description
3 Replies
rival-black
rival-blackOP3y ago
No description
rival-black
rival-blackOP3y ago
Why pageIndex changes to 0 when I change pageSize? I declared the pageIndex to start from 1, did I? any1?
rare-sapphire
rare-sapphire3y ago
Why do you need it to start at 1 and not 0?

Did you find this page helpful?