Skip to content

push on reactive variable triggers as many updates as there are elements in the appended array #16338

@shadow-identity

Description

@shadow-identity

Describe the bug

Unexpectedly push triggers as many updates as there are elements in the appended array.

const src = $state([0])
const push =  () => arr.push(...[1,2,3])
$inspect(src)
// update Array [ 0, 1 ]
// update Array(3) [ 0, 1, 2 ]
// update Array(4) [ 0, 1, 2, 3 ]

I think it is definitely a bug.

Reproduction

https://svelte.dev/playground/c121ee5b3bda44c3b146792a7d01d26f?version=5.35.5
Results can be seen in the console

System Info

Chrome, Firefox

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions