svelte-carousel icon indicating copy to clipboard operation
svelte-carousel copied to clipboard

Carousel doesn't re-render with reactive list of items

Open rodrigopineda028 opened this issue 3 years ago • 3 comments

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!

rodrigopineda028 avatar Jun 11 '21 05:06 rodrigopineda028

Hi @rodrigopineda028, Yes, correct. I'll think about that for upcoming releases. Thanks for the workaround.

vadimkorr avatar Jun 16 '21 10:06 vadimkorr

any update?

aleportillo avatar Oct 24 '22 19:10 aleportillo

any update ?

RobiMez avatar Aug 06 '23 19:08 RobiMez