[svelte] Why can't I bind to a `createQuery` result?
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 50.3k
- Forks
- 4.2k
- Avg merge
- 18h 25m
- Merged PRs (30d)
- 200
Description
Describe the bug
Using Svelte (v5.42.3) and Svelte Kit (v2.48.2) and @tanstack/svelte-query (v6.0.3).
If I have the component Player.svelte:
<script lang="ts">
import { createQuery } from '@tanstack/svelte-query';
const playerStore = createQuery(() => ({
queryKey: "key",
queryFn: playerById(page.params.player_id),
}));
let { data: player } = $derived(playerStore);
</script>
<FormPlayers bind:player={player} />
and FormPlayers.svelte:
<script lang="ts">
type Props = {
player: Player;
};
let {
player = $bindable(),
}: Props = $props();
</script>
{#each player.skills as skill, index (skill.id)}
<FormPlayerSkill bind:skill={player.skills[index]} />
{/each}
and FormPlayerSkill.svelte:
<script lang="ts">
type Props = {
skill: PlayerSkillInput;
};
let {
skill = $bindable()
}: Props = $props();
</script>
<Date bind:date={skill.date} />
I get the error:
FormPlayers.svelte:77 [svelte] binding_property_non_reactive
`bind:skill={player.skills[index]}` (src/routes/players/FormPlayers.svelte:40:4) is binding to a non-reactive property
https://svelte.dev/e/binding_property_non_reactive
Why? Isn't the let { data: player } = $derived(playerStore) assignable / bindable / editable / "Sveltable"?
Your minimal, reproducible example
I'll post ASAP (it's not easy).
Tanstack Query adapter
svelte-query
TanStack Query version
6.0.3
TypeScript version
5.9.3
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked Svelte playground and reproduce the warning using the Player.svelte, FormPlayers.svelte, and FormPlayerSkill.svelte examples in the report. Read the Svelte binding_property_non_reactive guidance alongside the $derived and $bindable behavior, then compare how the TanStack Svelte Query result is exposed. Done means establishing why this binding is non-reactive and documenting or confirming the supported behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 45/100