Skip to content

Commit

Permalink
fix: false reactive component warning (#9094)
Browse files Browse the repository at this point in the history
fixes #9082
  • Loading branch information
gtm-nayan committed Sep 20, 2023
1 parent 93b17c8 commit 26eb2a2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/shiny-mugs-tie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: silence false positive reactive component warning
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,19 @@ export default class InlineComponentWrapper extends Wrapper {
this.slots.set(name, slot_definition);
}
warn_if_reactive() {
const { name } = this.node;
const variable = this.renderer.component.var_lookup.get(name);
let { name } = this.node;
const top = name.split('.')[0]; // <T.foo/> etc. should check for T instead of "T.foo"
const variable = this.renderer.component.var_lookup.get(top);
if (!variable) {
return;
}
const ignores = extract_ignores_above_node(this.node);
this.renderer.component.push_ignores(ignores);
if (variable.reassigned || variable.export_name || variable.is_reactive_dependency) {
if (
variable.reassigned ||
variable.export_name || // or a prop
variable.mutated
) {
this.renderer.component.warn(this.node, compiler_warnings.reactive_component(name));
}
this.renderer.component.pop_ignores();
Expand Down

0 comments on commit 26eb2a2

Please sign in to comment.