Repository navigation
feat(fetchium): add useQueries to fetchium/react - #96
Merged
Merged
Conversation
abedell-phantom
approved these changes
Nov 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds
useQueriestofetchium/react, for a list of queries whose length or contents change between renders. Until now the only way to handle that was to render a child component per query, because callinguseQueryin a loop breaks the rules of hooks.Each entry takes the same
query,paramsandenabledasuseQuery, and the hook returns oneuseQuery-shaped result per entry, in order. A fixed list of different queries returns a typed tuple, and each entry's params are checked against its own query.The hook is small. One memoised thunk maps entries to
fetchQuery(orpeekQueryfor disabled entries), and Signalium'suseReactivesnapshot already handles arrays of query results, so each entry gets its own structurally shared snapshot. The thunk is keyed on each entry'squery,paramsandenabled, not on the array itself, so passing a new array with the same entries every render keeps every subscription.Behavior
useQuery: it unsubscribes and is collected aftergcTime.enabled: falseand Signalparamswork per entry, the same as inuseQuery.Tests
useQueryanduseQuery-stability suites now also run against a single-entryuseQueries, so every existinguseQueryscenario covers both hooks. Thedescribe.eachsits on the existing top-leveldescribe, so those diffs stay small.use-queries.test.tsxcovers the list-specific behavior: adding, removing, reordering and swapping entries; per-entryparamschanges andenabled; result identity; failures; shared entities; Signalparams; thunk reuse and rebuilds; and compile-timeparamchecks.queryid,params,enabled) is covered by a test that fails when that part is removed.Not included: a combine option and a useSuspenseQueries.