#do children of svelte components have to be svelte?

2 messages · Page 1 of 1 (latest)

vernal obsidian
#

So I have a svelte component on my homepage. It selects random cards to showcase from my data. It uses nanostores so that users can get a new set of random cards by clicking a button.

The component has the logic to fetch the data from the API, update the store etc. and display 3 cards.

The cards will not have any reactivity, so i don't actually need svelte there. But they will be called from the FeaturedCards.svelte component, something that looks like this:

{#each $featuredAtom as oneFeature}
  <Card cardData={oneFeature}/>
{/each}

My Card component has to be svelte, right? Or could i call an Astro component there?

vale cedar
#

Yes, Card has to be svelte in your example.

But Svelte components can render slot (ie. children) that you pass from its parent Astro component. So you might be able to create a workaround.