Skip to content

How to reference to an unknown input sent in the children snippet #15540

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

You must be logged in to vote

You cannot use a regular binding unless you have a property, you probably could use the function binding syntax, though. Using a property the rendering should be done as:

{@render children?.({ set this(el) { inputElement = el } })}

You can only make use of this argument by explicitly defining the snippet, it would look like this:

<FormElmBase>
	{#snippet children(context)}
		<input bind:this={context.this} />
	{/snippet}
</FormElmBase>

Playground

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by idavollen
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