From eb87f344d877b3fd7fa6a4b525eb40b4a3b6206d Mon Sep 17 00:00:00 2001 From: Jorge Cabiedes Acosta Date: Mon, 22 Sep 2025 14:48:03 -0700 Subject: [PATCH] [compiler] Don't throw calculate in render when there is a ref in the effect --- .../Validation/ValidateNoDerivedComputationsInEffects.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoDerivedComputationsInEffects.ts b/compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoDerivedComputationsInEffects.ts index ad9cf9cc9e..e2b19400f3 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoDerivedComputationsInEffects.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoDerivedComputationsInEffects.ts @@ -18,6 +18,7 @@ import { CallExpression, Instruction, isUseStateType, + isUseRefType, } from '../HIR'; import {eachInstructionLValue, eachInstructionOperand} from '../HIR/visitors'; import {isMutable} from '../ReactiveScopes/InferReactiveScopeVariables'; @@ -284,6 +285,11 @@ function validateEffect( } for (const instr of block.instructions) { + // Early return if any instruction is deriving a value from a ref + if (isUseRefType(instr.lvalue.identifier)) { + return; + } + if ( instr.value.kind === 'CallExpression' && isSetStateType(instr.value.callee.identifier) &&