Clean way to handle pagination.pageCount
, remove it from state?
#3902
-
(Using V8) Currently I have a bit of an issue with managing table state + having a paginated server response (currently using react-query but I think this is relevant in other cases). Currently the basic pattern is like so:
Now I have a bit of an issue, I currently planned on doing one of two solutions:
No other part of the state that I've found seems to have this issue, which is what made me remember - Basically: Is there any point to storing pageCount in state? Given the two scenarios I feel like either let it be derived, or allow an option to be provided for pageCount specifically. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Technically, the page count is state, or in other words, a persisted variable in the table instance that changes over time. It's either provided by the user or derived automatically. We'll have better docs around this soon, but I think the following should help:
In both cases, use
|
Beta Was this translation helpful? Give feedback.
Technically, the page count is state, or in other words, a persisted variable in the table instance that changes over time. It's either provided by the user or derived automatically. We'll have better docs around this soon, but I think the following should help:
options.state.pagination.pageCount
(-1
if it is unknown)In both cases, use
instance.getPageCount()
to get the page count (the table will know whether to pass the state through or derive it automatically)