mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[patch] Generate hook guards as function expressions
--- Arrow functions are not compatible with es3, which we sometimes target. This helps us make babel transform logic less complex
This commit is contained in:
+2
-1
@@ -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(
|
||||
|
||||
+4
-4
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user