-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Feature to disable useQuery and related specialised hooks #5827
Comments
Hi and thanks for the suggestion. That's not something we want to add though. May I ask why you don't use the AutocompleteInput? |
I think it makes sense for dependent queries: // fetch posts
const { ids, data: posts, loading: isLoading } = useGetList<Post>(
'posts',
{ page: 1, perPage: 20 },
{ field: 'name', order: 'ASC' },
{}
);
// then fetch categories for these posts
const { data: categories, loading: isLoading } = useGetMany<Category>(
'categories',
ids.map(id=> posts[id].category_id),
// run only if the first query returns non-empty result
{ enabled: ids.length > 0 }
); @ValentinH Do you feel like submitting a PR for that feature? |
@fzaninotto yes this is one of the use case I had in mind. I'm happy to work on a PR 🙂 @djhi to be honest, I actually started using the AutocompleteInput but I had issues. It might come from the fact that I don't use it in a |
@fzaninotto I created a WIP PR. Whenever you have time, could you tell me if this is going in the right direction? |
Fixed by #5849 |
Is your feature request related to a problem? Please describe.
I'm building an autocomplete input for a form outside of a
Create/Edit
page and I'd like to only call the API if the search text has at least 1 character.Here's the code I have (Autocomplete is coming from
mui-rff
):Describe the solution you'd like
I'd like to be able to pass a boolean option like
enabled
that would prevent the hook from calling the API if it'sfalse
. This is whatreact-query
is providing: https://react-query.tanstack.com/reference/useQuery#_topDescribe alternatives you've considered
I consider using
useMutation
and passgetList
as its type but it doesn't feel idiomatic.Additional context
Nothing else comes to my mind
The text was updated successfully, but these errors were encountered: