diff --git a/packages/react-refresh/src/ReactFreshBabelPlugin.js b/packages/react-refresh/src/ReactFreshBabelPlugin.js index c03ee8da94520..c21e4aa710512 100644 --- a/packages/react-refresh/src/ReactFreshBabelPlugin.js +++ b/packages/react-refresh/src/ReactFreshBabelPlugin.js @@ -306,7 +306,15 @@ export default function(babel) { } if (customHooksInScope.length > 0) { args.push( - t.arrowFunctionExpression([], t.arrayExpression(customHooksInScope)), + // TODO: We could use an arrow here to be more compact. + // However, don't do it until AMA can run them natively. + t.functionExpression( + null, + [], + t.blockStatement([ + t.returnStatement(t.arrayExpression(customHooksInScope)), + ]), + ), ); } return args; diff --git a/packages/react-refresh/src/__tests__/__snapshots__/ReactFreshBabelPlugin-test.js.snap b/packages/react-refresh/src/__tests__/__snapshots__/ReactFreshBabelPlugin-test.js.snap index 113f8b9739bdd..d3e5aa5a760d6 100644 --- a/packages/react-refresh/src/__tests__/__snapshots__/ReactFreshBabelPlugin-test.js.snap +++ b/packages/react-refresh/src/__tests__/__snapshots__/ReactFreshBabelPlugin-test.js.snap @@ -113,7 +113,9 @@ export default function App() { return