Break filters into own hook #7007
JuicyBenjamin
started this conversation in
Ideas
Replies: 1 comment
-
|
Hello @JuicyBenjamin, with const { result, query } = useList<IProduct, HttpError>({
resource: "products",
filters: [
// See here
{
field: "material",
operator: "eq",
value,
},
],
});You can actually create a custom hook to keep your filter state if you need to, that should work out of the box. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Recently I found myself needing to use the filters and setFilters that you would normally find in the useTable hook in a useList. I didn't think much of it and thought for sure that the api would have been standardised between these hooks. But alas, after looking at the code, it seems like the filters and setFilters are deeply ingrained in the useTable implementation. Granted I can just use the useTable over the useList for this specific use case, it just feels odd to use a hook that semantically tells me it has something to do with tables and then use it in a completely non table way.
So my proposal is add the filters and setFilters to the useList hook, so I can use it in a similar way. Or even better, break the filters and set filters into their own hook. This way I can have components that adjust the filters, without needing them to have getter and setter functions passed to them, as they could just interact with these filters themselves. Then the useTable hook could just use this new useFilters hook under the hood. I think this would match very well with the already predefined Refine approach.
Beta Was this translation helpful? Give feedback.
All reactions