Skip to content

[Svelte 5] Can't modify data prop #9905

Closed
@PP-Tom

Description

@PP-Tom

Describe the bug

This is useful for the CMS StoryBlok where it has a visual editor, it does this by updating the data json as you type. In Svelte 4 we can reassign this to the data attribute so the UI updates, in Svelte 5 this isn't possible. You can however use $state(data) to allow updates but in terms of backwards compatibility it might be useful to allow it.

Reproduction

Svelte 4: https://stackblitz.com/edit/sveltejs-kit-template-default-uwn6wh?file=src%2Froutes%2F%2Bpage.svelte
Svelte 5: https://stackblitz.com/edit/sveltejs-kit-template-default-6nqofs?file=src%2Froutes%2F%2Bpage.svelte

Logs

`Uncaught Error: Non-bound props cannot be mutated — use `bind:<prop>={...}` to make `count` settable. Fallback values can never be mutated.`

System Info

StackBlitz

Severity

blocking all usage of svelte

EDIT:
Thinking on all the projects that would require a decent sized refactor because of this, it would make me avoid updating to Svelte 5 for those projects. I've updated Severity to blocking upgrade due to this.

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