The `data` prop and subsequent `$derived` not mutable by default
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the bug
Now that $derived has been made writable. This is intended to make optimistic UI updates possible without having to use the $state in $derived.by dance. However, it still doesn't entirely solve the problem because data is a $state.raw, which means mutations to data or its deriveds won't update the UI. To make it work like Svelte 4 did, the trick is still needed, which is kinda ugly and not beginner friendly.
I believe making data a full $state instead of $state.raw would solve this problem. Any reasons not to do so?
Reproduction
https://svelte.dev/playground/a69b38c2e041412989ca3edb509a0138?version=5.25.2
Logs
System Info
Svelte 5.25.2
SvelteKit 2.20.2
Severity
annoyance
Additional Information
No response
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 reproduction and compare the behavior described for the data prop, $state.raw, and writable $derived values. Review the linked Svelte discussions for the intended tradeoffs; done means mutations to data or its derived values update the UI without the $state in $derived.by workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100