fascinating-indigo•13mo ago
useList, get current pageSize and pageIndex
Hi, how can I get the current pageSize and pageIndex, like useTable has in its tableProps but then for useList
2 Replies
Hi @BlackBearFTW. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To get the current
pageSize and pageIndex (which is referred to as current in refine) when using useList, you can access these values from the pagination property passed to the hook. Here's how you can do it:
The useList hook returns an object that includes the pagination property, which contains the current pagination state. You can destructure this object to access the current (equivalent to pageIndex) and pageSize values Documentation > Docs > Data > Hooks > useList > Properties > pagination (https://refine.dev/docs/data/hooks/use-list/#pagination-1).
It's worth noting that if you don't specify initial values for current and pageSize, they will default to 1 and 10 respectively.
You can also update these values dynamically:
This way, you can manage the pagination state in your component and pass it to useList, allowing you to update the current page or page size as needed Documentation > Docs > Data > Hooks > useList > Pagination > Retrieving the Total Row Count Part 1 (https://refine.dev/docs/data/hooks/use-list/#retrieving-the-total-row-count).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@490961337896402944> Kapa.ai is still learning and improving, please let me know how I did by reacting below.