diff --git a/packages/react-fast-refresh/client.js b/packages/react-fast-refresh/client.js index e5aa825bb2..e04feedf7c 100644 --- a/packages/react-fast-refresh/client.js +++ b/packages/react-fast-refresh/client.js @@ -16,9 +16,18 @@ if ( hmrEnabled && enabled ) { + let inBefore = false; module.hot.onRequire({ before(module) { + if (inBefore) { + // This is a module required while loading the react refresh runtime + // Do not initialize it to avoid an infinite loop + return; + } + + inBefore = true; init(module); + inBefore = false; } });