diff --git a/packages/react-refresh/src/__tests__/ReactFreshBabelPlugin-test.js b/packages/react-refresh/src/__tests__/ReactFreshBabelPlugin-test.js index 320cfe17041a6..f56f16069dd77 100644 --- a/packages/react-refresh/src/__tests__/ReactFreshBabelPlugin-test.js +++ b/packages/react-refresh/src/__tests__/ReactFreshBabelPlugin-test.js @@ -524,4 +524,16 @@ describe('ReactFreshBabelPlugin', () => { '". If you want to override this check, pass {skipEnvCheck: true} as plugin options.', ); }); + + it('does not get tripped by IIFEs', () => { + expect( + transform(` + while (item) { + (item => { + useFoo(); + })(item); + } + `), + ).toMatchSnapshot(); + }); }); 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 273d60cbe2a2a..4e2f8eec0518c 100644 --- a/packages/react-refresh/src/__tests__/__snapshots__/ReactFreshBabelPlugin-test.js.snap +++ b/packages/react-refresh/src/__tests__/__snapshots__/ReactFreshBabelPlugin-test.js.snap @@ -86,6 +86,18 @@ var _c; $RefreshReg$(_c, "App"); `; +exports[`ReactFreshBabelPlugin does not get tripped by IIFEs 1`] = ` +while (item) { + var _s = $RefreshSig$(); + + _s(_s(item => { + _s(); + + useFoo(); + }, "useFoo{}", true)(item), "useFoo{}", true); +} +`; + exports[`ReactFreshBabelPlugin generates signatures for function declarations calling hooks 1`] = ` var _s = $RefreshSig$();