Skip to content

State Binding Problem - ownership_invalid_mutation #15448

Answered by brunnerh
Jonyberry asked this question in Q&A
Discussion options

You must be logged in to vote

Unless you want to do something roundabout like passing a setter function around so the modification code technically exists in the form component, this probably will not work like this.

// in form
function setter(property, value) {
	formData[property] = value;
}
{@render children(formData, setter)}
<!-- usage site -->
<Form onSubmit={(values) => console.log(values)}>
	{#snippet children(formData, set)}
		<label for="email">Email</label>
		<input id="email" bind:value={() => formData.email, v => set('email', v)} />
		<!-- ... -->
	{/snippet}
</Form>

Example

I would recommend creating the state outside the form component ($state({})) and pass it via a binding instead.
You could do the init…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Jonyberry
Comment options

Answer selected by Jonyberry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants