chore: rewrite state_unsafe_mutation message (#12059)

pull/12062/head
Rich Harris 1 year ago committed by GitHub
parent 0ef906c569
commit 6588d85364
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: rewrite state_unsafe_mutation message

@ -66,9 +66,7 @@
## state_unsafe_mutation
> Unsafe mutations during Svelte's render or derived phase are not permitted in runes mode. This can lead to unexpected errors and possibly cause infinite loops.
>
> If the object is not meant to be reactive, declare it without `$state`
> Updating state inside a derived is forbidden. If the value should not be reactive, declare it without `$state`
## svelte_component_invalid_this_value

@ -279,14 +279,12 @@ export function state_prototype_fixed() {
}
/**
* Unsafe mutations during Svelte's render or derived phase are not permitted in runes mode. This can lead to unexpected errors and possibly cause infinite loops.
*
* If the object is not meant to be reactive, declare it without `$state`
* Updating state inside a derived is forbidden. If the value should not be reactive, declare it without `$state`
* @returns {never}
*/
export function state_unsafe_mutation() {
if (DEV) {
const error = new Error(`${"state_unsafe_mutation"}\n${"Unsafe mutations during Svelte's render or derived phase are not permitted in runes mode. This can lead to unexpected errors and possibly cause infinite loops.\n\nIf the object is not meant to be reactive, declare it without `$state`"}`);
const error = new Error(`${"state_unsafe_mutation"}\n${"Updating state inside a derived is forbidden. If the value should not be reactive, declare it without `$state`"}`);
error.name = 'Svelte error';
throw error;

Loading…
Cancel
Save