Skip to content

Commit c19c92d

Browse files
gtm-nayankelvinsjk
authored andcommitted
fix: false reactive component warning (sveltejs#9094)
fixes sveltejs#9082
1 parent c581b48 commit c19c92d

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

.changeset/shiny-mugs-tie.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: silence false positive reactive component warning

packages/svelte/src/compiler/compile/render_dom/wrappers/InlineComponent/index.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,19 @@ export default class InlineComponentWrapper extends Wrapper {
105105
this.slots.set(name, slot_definition);
106106
}
107107
warn_if_reactive() {
108-
const { name } = this.node;
109-
const variable = this.renderer.component.var_lookup.get(name);
108+
let { name } = this.node;
109+
const top = name.split('.')[0]; // <T.foo/> etc. should check for T instead of "T.foo"
110+
const variable = this.renderer.component.var_lookup.get(top);
110111
if (!variable) {
111112
return;
112113
}
113114
const ignores = extract_ignores_above_node(this.node);
114115
this.renderer.component.push_ignores(ignores);
115-
if (variable.reassigned || variable.export_name || variable.is_reactive_dependency) {
116+
if (
117+
variable.reassigned ||
118+
variable.export_name || // or a prop
119+
variable.mutated
120+
) {
116121
this.renderer.component.warn(this.node, compiler_warnings.reactive_component(name));
117122
}
118123
this.renderer.component.pop_ignores();

0 commit comments

Comments
 (0)