From b1dbc5955e1daea945d900bd043208d9f8efbf7f Mon Sep 17 00:00:00 2001 From: Mike Vitousek Date: Fri, 26 Jul 2024 15:52:23 -0700 Subject: [PATCH] [compiler] In change detection, be less precise about path dependencies ghstack-source-id: 0d3837641c960a8c049041bdccf36d9a806ffc4e Pull Request resolved: https://github.com/facebook/react/pull/30489 --- .../src/ReactiveScopes/CodegenReactiveFunction.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/CodegenReactiveFunction.ts b/compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/CodegenReactiveFunction.ts index c3a34499d2..a4288a776b 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/CodegenReactiveFunction.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/CodegenReactiveFunction.ts @@ -1442,7 +1442,11 @@ function codegenDependency( ): t.Expression { let object: t.Expression = convertIdentifier(dependency.identifier); if (dependency.path !== null) { - for (const path of dependency.path) { + let depPath = dependency.path; + if (cx.env.config.enableChangeDetection != null && depPath.length > 0) { + depPath = depPath.slice(0, -1) + } + for (const path of depPath) { object = t.memberExpression(object, t.identifier(path)); } }