`queryOptions` built via currying breaks SolidJS' Reactivity
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 55/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
- Ambito
- frontend
Direzione di ricerca
Inizia con la riproduzione collegata di solid-query-curry-reactivity, passa a quel branch, esegui pnpm install e pnpm dev e analizza il comportamento mostrato di RouteComponent. Traccia il modo in cui il risultato di curried fetchShellData viene passato attraverso useQuery; il lavoro è completato quando la query viene eseguita al mount del componente e Switch viene renderizzato senza richiedere l’accesso a q.data o createMemo().
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
To my knowledge, useQuery is designed so that whenever a component gets mounted (whenever a query key has 1 or more dependent), their queryFn is run (assuming no disabled state / dependent queries, etc).
On SolidJS, creating a queryOption via function currying will result in weird reactivity issue and breaks rendering / hydation code (not sure; TypeError: template is not a function at getNextElement (solid-js_web.js?v=018b852a:792:10) at __root.tsx:57:3...).
One simple reproducible behavior is that query wont be run until you call query.data in a component's body or memoize query.isSuccess in a createMemo().
The following is a reproduction case:
import { queryOptions, useQuery } from "@tanstack/solid-query";
import { createFileRoute } from "@tanstack/solid-router";
import { Match, Switch } from "solid-js";
export const Route = createFileRoute("/")({
component: RouteComponent,
});
export const fetchShellData = (slug: string) =>
queryOptions({
queryKey: ["shell-data", slug],
queryFn: () => {
return `ok: ${slug}`;
},
});
function RouteComponent() {
const opt = fetchShellData("/");
const q = useQuery(() => opt);
return (
<Switch>
<Match when={q.isPending}>PENDING</Match>
<Match when={q.isError}>ERROR</Match>
<Match when={q.isSuccess}>Success: {q.data}</Match>
</Switch>
);
}
Your minimal, reproducible example
https://tangled.org/angelo.fyi/solid-tanplate/tree/solid-query-curry-reactivity
Steps to reproduce
Assuming you've cloned the repo above:
- Switch to
solid-query-curry-reactivitybranch pnpm install&pnpm dev- Visit http://localhost:3000
Expected behavior
I expect that queries will be run automatically on component mount.
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
- OS: macOS Tahoe 26.4.1
- Browser: Arc Browser - 148.0.7778.168 (Official Build) (arm64)
Tanstack Query adapter
solid-query
TanStack Query version
5.100.11
TypeScript version
4.3.0
Additional context
No response
- Lingua principale
- TypeScript
- Stelle
- 50.3k
- Fork
- 4.2k
- Merge medio
- 22h 33m
- PR unite (30g)
- 214
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di TanStack/query
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 40/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
Tutte le issue di TanStack/query
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
bcgov/bc-wallet-mobile#4761 · 1 commento ·
-
external-issue to-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
area-deployment area-integrations triage:bot-seen
Difficoltà 2/5 Mezza giornata Idoneità per principianti 86/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
refactor
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100