Skip to content

Commit 4b1180c

Browse files
committed
fix(compiler): use shared isHookCalleeName in containsHookCall arm gate
Replace local isHookName predicate with shared isHookCalleeName so that unstable_use* and UNSTABLE_use* calls are correctly recognized as hooks. Without this, arm-bound content containing prefixed hooks could be incorrectly lowered, moving slot state onto a scope that is torn down on branch flips.
1 parent 68909d5 commit 4b1180c

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

‎packages/octane/src/compiler/compile.js‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23328,7 +23328,6 @@ function jsxArmRoot(node) {
2332823328
*/
2332923329
function containsHookCall(node) {
2333023330
const seen = new WeakSet();
23331-
const isHookName = (name) => name === 'use' || /^use[A-Z0-9_]/.test(name);
2333223331
const walk = (value) => {
2333323332
if (value == null || typeof value !== 'object') return false;
2333423333
if (Array.isArray(value)) {
@@ -23345,12 +23344,12 @@ function containsHookCall(node) {
2334523344
return false;
2334623345
if (value.type === 'CallExpression') {
2334723346
const callee = value.callee;
23348-
if (callee?.type === 'Identifier' && isHookName(callee.name)) return true;
23347+
if (callee?.type === 'Identifier' && isHookCalleeName(callee.name)) return true;
2334923348
if (
2335023349
callee?.type === 'MemberExpression' &&
2335123350
callee.computed !== true &&
2335223351
callee.property?.type === 'Identifier' &&
23353-
isHookName(callee.property.name)
23352+
isHookCalleeName(callee.property.name)
2335423353
)
2335523354
return true;
2335623355
}

0 commit comments

Comments
 (0)