Closed
Description
Is it possible to pass events to dynamic components?
E.g. pass on:click
as props and recieve the click event.
Made a full exmaple: https://svelte.dev/repl/a16dd36f0265408a9c42409986b44acd?version=3.24.1
Short Version:
Example.svelte
<script>
export let component
export let props
</script>
<svelte:component
this={component}
{...props}
></svelte:component>
Example call
<script>
import Example from './Example.svelte'
const component = ... // some svelte component e.g. a Button
const props = {
'on:click' = (e) => console.log('THIS SHOULD BE CALLED')
}
</script>
<Example {component} {props}></Example>
The on:click
will not be triggered, only if i wrote it like this
<Example {component} {props} on:click={(e) => props['on:click'](e)}></Example>
But in this case i have to call the click targets manually.
Metadata
Metadata
Assignees
Labels
No labels