I am trying to render conditional elements/slots inside an #each block in svelte and I cannot figure out why it does not work. The following code does not work in Svelte:
<Menu>
{#each items as item}
<Item>
{#if item.icon}
<Icon slot="icon" icon={item.icon} />
{/if}
{#if item.label}
<Label slot="label">{item.label}</Label>
{/if}
</Item>
{/each}
</Menu>
There are a decent amount of moving parts so I wired up a small Repl to show this in action:
https://svelte.dev/repl/b089c2c379e9404596445c16311bd1b9?version=3.50.1