svelte: Svelte 5: Deeply nested state doesn't re-render when looping

Describe the bug

It seems that when looping through a deeply nested object, svelte doesn’t re-render when looping through object.

No errors are thrown in the logs which makes me think this may be a bug.

Reproduction

Repl

Click the update button and observe that the JSON.stringify correctly shows the update, but the each block isn’t updated with the new value.

Note: I’m using the $inspect to force the compiler to svelte 5 mode. Without it, it works as expected.

Logs

No response

System Info

Browser: Edge

Severity

blocking all usage of svelte

About this issue

  • Original URL
  • State: closed
  • Created 4 months ago
  • Comments: 17 (15 by maintainers)

Commits related to this issue

Most upvoted comments

Additional PRs related to this:

(Fixing #each + $store scenarios using index or entire items as keys.)

@dummdidumm I’ll take a look at this tomorrow and see what we can do 😃

The #each loop variable in runes mode is no longer “connected” to the reactivity of the source array.

So unless you make the items themselves reactive, you need to use access via key on the source (which is less efficient as far as I am aware).

This can’t be the expected behavior for stores, this is clearly a regression that needs to be fixed.