From afa8ed496b6ac221678465a90856d9a17370f2a9 Mon Sep 17 00:00:00 2001 From: Anton Korzunov Date: Wed, 10 Jul 2019 21:03:33 +1000 Subject: [PATCH] fix: do not update hooks while updating hooks, fixes #1294 --- src/proxy/createClassProxy.js | 6 ++++-- src/reconciler/proxies.js | 3 +-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/proxy/createClassProxy.js b/src/proxy/createClassProxy.js index 65707481f..e23f084a4 100644 --- a/src/proxy/createClassProxy.js +++ b/src/proxy/createClassProxy.js @@ -341,13 +341,13 @@ function createClassProxy(InitialComponent, proxyKey, options = {}) { } if (NextComponent === CurrentComponent) { - return; + return false; } // Prevent proxy cycles const existingProxy = proxies.get(NextComponent); if (existingProxy) { - return; + return false; } isFunctionalComponent = !isReactClass(NextComponent); @@ -412,6 +412,8 @@ function createClassProxy(InitialComponent, proxyKey, options = {}) { classUpdatePostponed = classHotReplacement; } } + + return true; } update(InitialComponent); diff --git a/src/reconciler/proxies.js b/src/reconciler/proxies.js index e3deb3019..43850b3da 100644 --- a/src/reconciler/proxies.js +++ b/src/reconciler/proxies.js @@ -57,8 +57,7 @@ export const updateProxyById = (id, type, options = {}) => { id, merge({}, renderOptions, { proxy: componentOptions.get(type) || {} }, options), ); - } else { - proxiesByID[id].update(type); + } else if (proxiesByID[id].update(type)) { // proxy could be registered again only in case of HMR incrementHotGeneration(); }