Skip to content

Commit

Permalink
add warning
Browse files Browse the repository at this point in the history
  • Loading branch information
trueadm committed Oct 17, 2024
1 parent 8fbbd55 commit 63718a1
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### legacy_reactive_block_mutation
### legacy_recursive_reactive_block

```
Detected a migrated `$:` reactive block that both accesses and updates the same reactive value. This may cause recursive updates when converted to an `$effect`.
Expand Down
2 changes: 1 addition & 1 deletion packages/svelte/messages/legacy-warnings/warnings.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## legacy_reactive_block_mutation
## legacy_recursive_reactive_block

> Detected a migrated `$:` reactive block that both accesses and updates the same reactive value. This may cause recursive updates when converted to an `$effect`.
2 changes: 1 addition & 1 deletion packages/svelte/src/legacy/legacy-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export function run(fn) {
var effect = /** @type {import('#client').Effect} */ (active_effect);
// If the effect is immediately made dirty again, mark it as maybe dirty to emulate legacy behaviour
if ((effect.f & DIRTY) !== 0) {
w.legacy_reactive_block_mutation();
w.legacy_recursive_reactive_block();
set_signal_status(effect, MAYBE_DIRTY);
}
});
Expand Down
6 changes: 3 additions & 3 deletions packages/svelte/src/legacy/warnings.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ var normal = 'font-weight: normal';
/**
* Detected a migrated `$:` reactive block that both accesses and updates the same reactive value. This may cause recursive updates when converted to an `$effect`.
*/
export function legacy_reactive_block_mutation() {
export function legacy_recursive_reactive_block() {
if (DEV) {
console.warn(`%c[svelte] legacy_reactive_block_mutation\n%cDetected a migrated \`$:\` reactive block that both accesses and updates the same reactive value. This may cause recursive updates when converted to an \`$effect\`.`, bold, normal);
console.warn(`%c[svelte] legacy_recursive_reactive_block\n%cDetected a migrated \`$:\` reactive block that both accesses and updates the same reactive value. This may cause recursive updates when converted to an \`$effect\`.`, bold, normal);

Check failure on line 13 in packages/svelte/src/legacy/warnings.js

View workflow job for this annotation

GitHub Actions / Lint

Unexpected console statement
} else {
// TODO print a link to the documentation
console.warn("legacy_reactive_block_mutation");
console.warn("legacy_recursive_reactive_block");

Check failure on line 16 in packages/svelte/src/legacy/warnings.js

View workflow job for this annotation

GitHub Actions / Lint

Unexpected console statement
}
}

0 comments on commit 63718a1

Please sign in to comment.