Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce useList #6321

Merged
merged 4 commits into from
Jun 21, 2021
Merged

Introduce useList #6321

merged 4 commits into from
Jun 21, 2021

Conversation

djhi
Copy link
Contributor

@djhi djhi commented Jun 1, 2021

Introduces a new hook that applies list filtering, sorting and pagination on the provided data, either in memory or through the provided function. This can be useful for example when you can't change some API routes which return enough data to make those features necessary but you can't or don't want to implement them in your dataProvider.

@djhi djhi added the WIP Work In Progress label Jun 1, 2021
@djhi djhi added RFR Ready For Review and removed WIP Work In Progress labels Jun 2, 2021
@fzaninotto fzaninotto merged commit 3a1bbec into next Jun 21, 2021
@fzaninotto fzaninotto deleted the use-list branch June 21, 2021 15:44
@fzaninotto fzaninotto added this to the 3.17.0 milestone Jun 21, 2021
@fzaninotto
Copy link
Member

I merged it a bit too fast. Could you open a new PR with the following adjustments:

  • Remove the ids and data params - they don't make sens in that context
  • remove the 'initial' prefix in all arguments.
  • update JSDoc accordingly

This should allow a simpler call, like:

 const listContext = useList({
    data,
    ids,
    filter: { is_published: truev},
    sort: { field: 'title', order: 'ASC' },
    page: 1,
    perPage: 10,
    basePath: '/resource';
    resource: 'resource';
 });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants