svelte-carousel
svelte-carousel copied to clipboard
Carousel doesn't re-render with reactive list of items
I've been using this awesome component but I encountered an issue when looping with a reactive list of items. It seems that the Carousel doesn't re-render when the state of the list of items changes. For example, adding or removing items dynamically. I think it's because the items are added on the 'onMount' only. The workaround for me was to wrap the component in a {#key} block like this:
{#key items}
<Carousel>
{#each items as item (item.id)}
// code here...
{/each}
</Carousel>
{/key}
With this, the component re-renders every time I add/remove items dynamically (the state of the list changes). Hope it helps!
Hi @rodrigopineda028, Yes, correct. I'll think about that for upcoming releases. Thanks for the workaround.
any update?
any update ?