refinedev / refine

A React Framework for building internal tools, admin panels, dashboards & B2B apps with unmatched flexibility.
https://refine.dev
MIT License
25.92k stars 1.96k forks source link

[FEAT] `useTable`'s state names `current` and `setCurrent` are confusing. #6087

Closed alicanerdurmaz closed 1 hour ago

alicanerdurmaz commented 2 days ago

Is your feature request related to a problem? Please describe.

The return values of useTable related to pagination are as follows:

import {
 useTable
} from "@refinedev/core";

const { current, setCurrent, pageSize, setPageSize, pageCount } = useTable();

The purpose of current and setCurrent is to change the page, but it is unclear what current refers to.

Describe alternatives you've considered

No response

Additional context

No response

Describe the thing to improve

  1. current and setCurrent should be deprecated.
  2. useTable should return page and setPage, serving the same purpose.
  3. pagination.page should be added to useTable props, and if pagination.page is provided, it should override pagination.current.
  4. Both current and page should be sent to dataProvider to prevent breaking changes.
  5. syncWithLocation should work with both fields without breaking changes.
  6. useParsed should work with both fields without breaking changes.
const { current, setCurrent, pageSize, setPageSize, pageCount } = useTable({
  pagination: {
    page: 5,
    current: 5,
  },
});
alicanerdurmaz commented 1 hour ago

After discussing this with the core team, we decided to implement it with Refine@5 because the syncWithLocation feature will cause a breaking change.