From c714b9fcdeb08b1da4882f9bef9d3ef8fbb11dc8 Mon Sep 17 00:00:00 2001 From: Raashish Aggarwal <94279692+raashish1601@users.noreply.github.com> Date: Tue, 5 May 2026 18:35:05 +0530 Subject: [PATCH] Fix refs rule JSX prop aliasing --- .../Validation/ValidateNoRefAccessInRender.ts | 13 ---- .../ReactCompilerRuleTypescript-test.ts | 73 +++++++++++++++++++ 2 files changed, 73 insertions(+), 13 deletions(-) diff --git a/compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoRefAccessInRender.ts b/compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoRefAccessInRender.ts index 7da564205475..416398d79fea 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoRefAccessInRender.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoRefAccessInRender.ts @@ -149,19 +149,6 @@ function collectTemporariesSidemap(fn: HIRFunction, env: Env): void { } break; } - case 'PropertyLoad': { - if ( - isUseRefType(value.object.identifier) && - value.property === 'current' - ) { - continue; - } - const temp = env.lookup(value.object); - if (temp != null) { - env.define(lvalue, temp); - } - break; - } } } } diff --git a/packages/eslint-plugin-react-hooks/__tests__/ReactCompilerRuleTypescript-test.ts b/packages/eslint-plugin-react-hooks/__tests__/ReactCompilerRuleTypescript-test.ts index a0d0f6bdbc8e..a5e7e111f81d 100644 --- a/packages/eslint-plugin-react-hooks/__tests__/ReactCompilerRuleTypescript-test.ts +++ b/packages/eslint-plugin-react-hooks/__tests__/ReactCompilerRuleTypescript-test.ts @@ -195,7 +195,80 @@ const tests: CompilerTestCases = { ], }; +const refsTests: CompilerTestCases = { + valid: [ + { + name: 'Allows JSX ref from a props member without marking all props as refs', + filename: 'test.tsx', + code: normalizeIndent` + function Test(props) { + return ( +