From 26eb2a2f89993322af714031c26721e6c6081ac8 Mon Sep 17 00:00:00 2001 From: gtmnayan <50981692+gtm-nayan@users.noreply.github.com> Date: Wed, 20 Sep 2023 13:49:16 +0545 Subject: [PATCH] fix: false reactive component warning (#9094) fixes #9082 --- .changeset/shiny-mugs-tie.md | 5 +++++ .../render_dom/wrappers/InlineComponent/index.js | 11 ++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 .changeset/shiny-mugs-tie.md diff --git a/.changeset/shiny-mugs-tie.md b/.changeset/shiny-mugs-tie.md new file mode 100644 index 0000000000..58d0e5537f --- /dev/null +++ b/.changeset/shiny-mugs-tie.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: silence false positive reactive component warning diff --git a/packages/svelte/src/compiler/compile/render_dom/wrappers/InlineComponent/index.js b/packages/svelte/src/compiler/compile/render_dom/wrappers/InlineComponent/index.js index 77fb1ac96b..d5cf8341dc 100644 --- a/packages/svelte/src/compiler/compile/render_dom/wrappers/InlineComponent/index.js +++ b/packages/svelte/src/compiler/compile/render_dom/wrappers/InlineComponent/index.js @@ -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]; // 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();