-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[Svelte 5] Can't modify data prop #9905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think that is desired, so not a bug but a feature If that is true, would that issue be a feature request to allow non-bound props to be mutated? Not sure though UpdateApparently, it indeed does seem like a bug 🐛 |
@Malix-off, what is the reasoning for the change? As far as I'm aware Rich was wanting backwards compatibility with Svelte 4 and this would break 90% of my projects on update and require some refactoring. It will also break most people's StoryBlok setup with Svelte I should imagine (https://www.storyblok.com/tp/add-a-headless-cms-to-svelte-in-5-minutes#listening-to-changes-in-the-visual-editor). |
It looks like a bug to me |
I've updated to Currently this completely breaks StoryBlok with Svelte. |
Can you give an example how this breaks StoryBlok with Svelte? In which way do you interact with StoryBlok and mutate its state so that it currently breaks? |
By doing `bind:data/form`, the layout/child components are allowed to mutate those properties Related sveltejs/svelte#9905
Since #10464 this will only be a warning and not an error anymore. |
@dummdidumm I think @PP-Tom meant the code from the Storyblok documentation (here Section: "Listening to changes in the Visual Editor"): <script>
import { onMount } from "svelte";
import { useStoryblokBridge, StoryblokComponent } from "@storyblok/svelte";
export let data;
onMount(() => {
useStoryblokBridge(
data.story.id,
// modifying data here
(newStory) => (data.story = newStory)
);
});
</script>
<div>
{#if data.story}
<StoryblokComponent blok={data.story.content} />
{/if}
</div> But I think one could just put the |
Yeah looks like it. The other alternative would be to use reassignment ( |
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
System Info
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.The text was updated successfully, but these errors were encountered: