diff --git a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/CodegenReactiveFunction.ts b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/CodegenReactiveFunction.ts index 00f4012838..701554d469 100644 --- a/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/CodegenReactiveFunction.ts +++ b/compiler/packages/babel-plugin-react-forget/src/ReactiveScopes/CodegenReactiveFunction.ts @@ -1019,7 +1019,8 @@ function createCallExpression( const hookGuard = config.enableEmitHookGuards; if (hookGuard != null && isHook) { - const iife = t.arrowFunctionExpression( + const iife = t.functionExpression( + null, [], t.blockStatement([ createHookGuard( diff --git a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/flag-enable-emit-hook-guards.expect.md b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/flag-enable-emit-hook-guards.expect.md index cd5e0374b6..813cc62bb5 100644 --- a/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/flag-enable-emit-hook-guards.expect.md +++ b/compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/flag-enable-emit-hook-guards.expect.md @@ -66,7 +66,7 @@ function Component(t47) { } else { t0 = $[0]; } - const [state, setState] = (() => { + const [state, setState] = (function () { try { $dispatcherGuard(2); return useState(t0); @@ -92,7 +92,7 @@ function Component(t47) { t1 = $[2]; t2 = $[3]; } - (() => { + (function () { try { $dispatcherGuard(2); return useEffect(t1, t2); @@ -101,11 +101,11 @@ function Component(t47) { } })(); print(identity(value + state)); - return (() => { + return (function () { try { $dispatcherGuard(2); return ObjectWithHooks.useIdentity( - (() => { + (function () { try { $dispatcherGuard(2); return useContext(MyContext);