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
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
eachblock if$selectedItemis 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
eachblock when the$selectedItemis updated.I would expect in the latter case that a re-render would be triggered as well, since
$selectedItemis updatedSee the example in the REPL for the mentioned behavior: https://svelte.dev/repl/57a0f818a94642ea8413a6372b6ecc38?version=3.2.0
Using Svelte v3.2.0