From a804db8ab947e41b93ce3f2f4bae77c0ac54f055 Mon Sep 17 00:00:00 2001 From: Amit Saroj Date: Thu, 4 Jun 2026 10:54:07 +0530 Subject: [PATCH 1/2] [compiler] Fix JSX tags starting with _ treated as host components --- .../packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts b/compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts index 452aa0ce329d..07e6862039ab 100644 --- a/compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts +++ b/compiler/packages/babel-plugin-react-compiler/src/HIR/BuildHIR.ts @@ -3409,7 +3409,7 @@ function lowerJsxElementName( const exprLoc = exprNode.loc ?? GeneratedSource; if (exprPath.isJSXIdentifier()) { const tag: string = exprPath.node.name; - if (tag.match(/^[A-Z]/)) { + if (!tag.match(/^[a-z]/)) { const kind = getLoadKind(builder, exprPath); return lowerValueToTemporary(builder, { kind: kind, From 8893a48a623d3f390dc898487453d34450f994d5 Mon Sep 17 00:00:00 2001 From: Amit Saroj Date: Thu, 4 Jun 2026 10:56:55 +0530 Subject: [PATCH 2/2] [compiler] Add test fixture for underscore-prefixed JSX component tag --- .../compiler/jsx-underscore-prefix-component.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/jsx-underscore-prefix-component.js diff --git a/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/jsx-underscore-prefix-component.js b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/jsx-underscore-prefix-component.js new file mode 100644 index 000000000000..41244903c153 --- /dev/null +++ b/compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/jsx-underscore-prefix-component.js @@ -0,0 +1,14 @@ +// @flow strict-local + +/** + * Regression test: JSX tags prefixed with `_` must be treated as + * user-defined components, not as host (builtin) elements. + * + * By JSX convention, a tag is a host element only if its first character is a + * lowercase ASCII letter [a-z]. A tag starting with `_` (or `$`, a digit, or + * any non-lowercase character other than a member-expression) is a component + * and must be loaded from scope and tracked as a dependency. + */ +function Foo({_Bar}) { + return <_Bar>{() =>
}; +}