Skip to content

Commit

Permalink
fix: do not update hooks while updating hooks, fixes #1294
Browse files Browse the repository at this point in the history
  • Loading branch information
theKashey committed Jul 10, 2019
1 parent b0ee8db commit afa8ed4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/proxy/createClassProxy.js
Expand Up @@ -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);
Expand Down Expand Up @@ -412,6 +412,8 @@ function createClassProxy(InitialComponent, proxyKey, options = {}) {
classUpdatePostponed = classHotReplacement;
}
}

return true;
}

update(InitialComponent);
Expand Down
3 changes: 1 addition & 2 deletions src/reconciler/proxies.js
Expand Up @@ -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();
}
Expand Down

0 comments on commit afa8ed4

Please sign in to comment.