Skip to content

filtering with store value doesn't trigger re-render #2693

@janwillemtulp

Description

@janwillemtulp

When filtering a list using a store value, it doesn't trigger a re-render if the filtering is done inline in an expression. It does trigger a re-render if you create a reactive variable first.

This does not trigger a re-render of the code inside the each block if $selectedItem is updated:
{#each $list.filter(d => d === $selectedItem) as item}

But first declaring this...
$: filteredList = $list.filter(d => d === $selectedItem) as item}
... and then ...
{#each filteredList as item}
... does re-render the each block when the $selectedItem is updated.

I would expect in the latter case that a re-render would be triggered as well, since $selectedItem is updated

See the example in the REPL for the mentioned behavior: https://svelte.dev/repl/57a0f818a94642ea8413a6372b6ecc38?version=3.2.0

Using Svelte v3.2.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions