Skip to content

Commit

Permalink
Add a comment why replacing shouldComponentUpdate is needed
Browse files Browse the repository at this point in the history
  • Loading branch information
koba04 committed Sep 26, 2017
1 parent 971f501 commit ea4b71c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/enzyme/src/ShallowWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,10 @@ class ShallowWrapper {
const prevState = instance.state;
const prevContext = instance.context;
let shouldRender = true;
// dirty hack: avoid calling shouldComponentUpdate twice
// This is a dirty hack but it requires to know the result of shouldComponentUpdate.
// When shouldComponentUpdate returns false we shouldn't call componentDidUpdate.
// shouldComponentUpdate is called in `instance.setState`
// so we replace shouldComponentUpdate to know the result and restore it later.
let originalShouldComponentUpdate;
if (
this[OPTIONS].lifecycleExperimental &&
Expand Down

0 comments on commit ea4b71c

Please sign in to comment.