From fffebc20e3be82556ca8b0f5833c2dcc1e809fac Mon Sep 17 00:00:00 2001 From: zodern Date: Fri, 10 Sep 2021 16:18:06 -0500 Subject: [PATCH] Fix infinite loop --- packages/react-fast-refresh/client.js | 9 +++++++++ 1 file changed, 9 insertions(+) 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; } });