You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The solution worked in Svelte 4 because the data props was mutable. In Svelte 5 it's no longer the case. This issue has been brought up several times: #12999 #14536
I assume that the tutorial is migrated from Svelte 4 using the migration tool which just changes export let data to let { data = $bindable() } = $props() which currently does nothing.
However, is this pattern really what should be put into the official tutorial to teach new people about Svelte/Kit?
To my understanding, there are 3 possible solutions:
Do nothing, just use $effect, which I only consider as a workaround.
Make data = $bindable() work, which should make data and page.data mutable for optimistic UI updates. Best solution IMO. It worked in Svelte 4 so why can't it work in Svelte 5?
Something else like $state.link.
So what should be done about this tutorial in particular and the underlying problem in general?
The text was updated successfully, but these errors were encountered:
Today somebody in the Discord server asked why the UI doesn't update with the official solution:
https://svelte.dev/tutorial/kit/post-handlers
The solution worked in Svelte 4 because the
data
props was mutable. In Svelte 5 it's no longer the case. This issue has been brought up several times:#12999
#14536
I assume that the tutorial is migrated from Svelte 4 using the migration tool which just changes
export let data
tolet { data = $bindable() } = $props()
which currently does nothing.I offered this answer:
However, is this pattern really what should be put into the official tutorial to teach new people about Svelte/Kit?
To my understanding, there are 3 possible solutions:
$effect
, which I only consider as a workaround.data = $bindable()
work, which should makedata
andpage.data
mutable for optimistic UI updates. Best solution IMO. It worked in Svelte 4 so why can't it work in Svelte 5?$state.link
.So what should be done about this tutorial in particular and the underlying problem in general?
The text was updated successfully, but these errors were encountered: