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
When passing an object to a child prop, the child can update it as if it were bound, even without using bind:. When not using an object, bind: is required.
Reproduction
Svelte 5 REPL EDIT: This might be a better REPL to show that there's no difference.
This is a combination of intended behavior and a known limitation with a runtime check.
You are discouraged from mutating state that has been one-way passed into your component. Your original Svelte 5 REPL logs a warning about this at run time in dev mode. (It won't in prod mode so we can avoid the overhead of checking for these mutations at runtime.)
In your revised Svelte 5 REPL, you are both passing it in as a one-way prop and passing it in as a two-way binding to different instances of the child component, and there isn't a good way at runtime for the first instance of the child component to know that it shouldn't own the counter variable while the second one should.
In the Svelte 4 REPL, the parent component's counter value is still mutated (which can be seen by adding something like setInterval(() => console.log(counter), 1000) to the parent component), but it just doesn't find out about it because of a limitation of the compile-time dependency tracking.
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
When passing an object to a child prop, the child can update it as if it were bound, even without using
bind:
. When not using an object,bind:
is required.Reproduction
Svelte 5 REPLEDIT: This might be a better REPL to show that there's no difference.Svelte 4 REPL
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: