Skip to content

Derived isn't mutated when reassigned synchronously after definition #15590

Closed
@thes01

Description

@thes01

Describe the bug

I just wanted to give the new mutable deriveds a try and did a simple test:

let thing = $derived(state); // or just $derived('old')
thing = 'new';

However, in the output, I still see the old value, not the updated one.

Note: this works

let thing = $derived('old');
Promise.resolve().then(() => { thing = 'new' });

UPDATE: If you put a console.log before the reassignment, then it starts working.

Reproduction

https://svelte.dev/playground/f447b4a9ec5d4271a9d1b187ab91a560?version=5.25.2

Logs

System Info

not relevant

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