I basically need to be able to trigger something within one or more components (that are being dynamically added via svelte:component) when an icon/button within the parent component is clicked. e.g. I need to hook the parts denoted with ** below:-
<script>
let charts = [
ChartA,
ChartB,
ChartC
];
</script>
{#each charts as chart, i}
<div class="wrapper">
<div class="icon" on:click={**HowToPassClickEventToComponent**}></div>
<div class="content">
<svelte:component this={charts[i]} {**clickedEvent**}/>
</div>
</div>
{/each}
I was able to get something working by unsing an array of props but each component is notified when the array changes so this is not very clean.
I have searched both Google and StackOverflow as well as asking this question within the Svelte Discord channel with currently no luck.
Svelte Repl showing the problem
This seems like such a simple requirement but after a couple of days I remain stuck so any advice on how to pass events into dynamic components is much appreciated.