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

Clarify: “ violate the rules of hooks” #57

Open
derolf opened this issue Oct 1, 2021 · 3 comments
Open

Clarify: “ violate the rules of hooks” #57

derolf opened this issue Oct 1, 2021 · 3 comments

Comments

@derolf
Copy link

derolf commented Oct 1, 2021

https://sveltequery.vercel.app/guides/parallel-queries

Dynamic Parallel Queries with useQueries

If the number of queries you need to execute is changing from render to render, you cannot use manual querying since that would violate the rules of hooks. Instead, Svelte Query provides a useQueries hook, which you can use to dynamically execute as many queries in parallel as you'd like.

I am verify familiar with the concept of hooks and all their pitfalls in React, but this is the first time I read something mentioning rules of hooks in Svelte.

Can you please elaborate what can go one calls useQuery conditionally?

@paolotiu
Copy link

paolotiu commented Oct 4, 2021

I think the docs were basically copied and pasted from react-query.

@derolf
Copy link
Author

derolf commented Oct 4, 2021

Yeah, that’s what I figured out as well. Anyway, I think the docs should be fixed…

@derolf derolf closed this as completed Oct 4, 2021
@derolf derolf reopened this Oct 4, 2021
@SomaticIT
Copy link
Collaborator

Since useQuery creates a Readable store. It can't be conditionnally executed (svelte compiler will try to subscribe to it anyway).

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

No branches or pull requests

3 participants