Closed
Description
Describe the bug
Given the following state variable let arr = $state<string[]>([])
. When mutating it with arr.push("...")
and arr.splice(i, 1)
reactivity breaks after adding at least two items to the array and then removing all of them. Afterwards adding an item again does not update the UI.
Reproduction
This REPL contains an example of the potential bug and two alternatives to mutating the array which work as expected. The working alternatives both reassign the value of the array. That's why I'm unsure if the reactivity breaking when only using splice
might actually be the the expected behavior.
Logs
No response
System Info
System:
OS: Linux 6.1 NixOS 23.11 (Tapir) 23.11 (Tapir)
CPU: (8) x64 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz
Memory: 12.13 GB / 15.27 GB
Container: Yes
Shell: 5.9 - /run/current-system/sw/bin/zsh
Binaries:
Node: 20.9.0 - /etc/profiles/per-user/biwecka/bin/node
npm: 10.1.0 - /etc/profiles/per-user/biwecka/bin/npm
npmPackages:
svelte: ^5.0.0-next.1 => 5.0.0-next.28
Severity
annoyance
Metadata
Metadata
Assignees
Labels
No labels