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

prefetch hooks can not be called conditionaly #1756

Open
zdarovka opened this issue Dec 19, 2024 · 0 comments
Open

prefetch hooks can not be called conditionaly #1756

zdarovka opened this issue Dec 19, 2024 · 0 comments
Labels
tanstack-query TanStack Query related issue

Comments

@zdarovka
Copy link

What are the steps to reproduce this issue?

  1. enable the 'usePrefetch' for the react-query client
  2. try to use the prefetch hook conditionaly, for example on click event handler

What happens?

Due to the nature of the hooks, you can not call them condionally. Also the enabled switch is ignored by react query if is a prefetch. So the prefetch hooks can not be called in event handlers such as on click, etc.

What were you expecting to happen?

I would expect to be able to pass user data as parameter for the prefetch query.

@melloware melloware added the tanstack-query TanStack Query related issue label Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tanstack-query TanStack Query related issue
Projects
None yet
Development

No branches or pull requests

2 participants