Skip to content

Override derived array using push is not reactive #16887

@Stadly

Description

@Stadly

Describe the bug

Pushing to a derived array is not reactive:

<script>
	let derived = $derived(["initial"]);
</script>

<p>{derived}</p>
<button onclick={
	() => derived.push("more") // Not reactive
}>push</button>

<button onclick={
	() => derived = [...derived, "spread"] // Reactive
}>spread</button>

Reproduction

https://svelte.dev/playground/1f9c9d543286412695fe03bdfe0ab73b?version=5.39.8

Logs

System Info

The latest Playground

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