-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Svelte 5: faulty ownership_invalid_binding errors #11399
Comments
repro here. it does indeed look like a bug |
@Rich-Harris I'm not sure whether this should be a separate issue, but it's related if I get what you all are trying to do with ownership. If I pass state unbound into another component... <script>
import SomeForm from './SomeForm.svelte'
let object = $state({
name: {first: 'Buffy', last: 'Arbuthnot'},
luckyNumbers: [13]
});
</script>
<h2>In App</h2>
<pre>{JSON.stringify(object, null, 2)}</pre>
<h2>Form</h2>
<SomeForm {object}/> ...and forget to properly destructure stuff... <script>
// SomeForm.svelte
let {object} = $props();
let data = $state({
// not properly destructured...
name: object.name,
// ditto...
luckyNumbers: object.luckyNumbers
});
const deleteLuckyNumber = (index) => {
data.luckyNumbers.splice(index, 1)
}
const addLuckyNumber = (index) => {
data.luckyNumbers.push(Math.floor(Math.random() * 1000))
}
</script> ...then it seems to me that I should get the Sorry if I got the wrong end of the stick. |
Yep, that looks like another (albeit separate) bug, it should recognise that |
Describe the bug
I'm getting this error...
...when doing something like this...
So:
RouteActionModal
, basically some layout and focus-trapping stuff.EditPricingForm
, shown simplified above.PricingControls
. This is split out since I use it in other forms.children
.RouteActionModal
andEditPricingForm
.I'm assuming this is a bug. If it's not, I assume the workaround would be to avoid abstracting out
PricingControls
. That's doable but way less than ideal.The bindings don't work when you build (i.e. it's not HMR.)
Reproduction
Glad to create a minimal repro, but let me know if it's really a bug first.
Logs
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: