-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix to call componentDidUpdate on setState of React v16 #1261
Conversation
@@ -387,7 +387,7 @@ class ShallowWrapper { | |||
// so we replace shouldComponentUpdate to know the result and restore it later. | |||
let originalShouldComponentUpdate; | |||
if ( | |||
this[OPTIONS].lifecycleExperimental && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, i wonder if this is causing a number of other bugs related to lifecycle methods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't find issues causing by this in enzyme repository, but there might be in outside.
@@ -1026,7 +1026,7 @@ describe('shallow', () => { | |||
expect(wrapper.first('div').text()).to.equal('yolo'); | |||
}); | |||
|
|||
it('should call componentWillReceiveProps, shouldComponentUpdate and componentWillUpdate with merged newProps', () => { | |||
it('should call componentWillReceiveProps, shouldComponentUpdate and componentWillUpdate and componentDidUpdate with merged newProps', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have a duplicate "and" here (before both the ultimate and penultimate items); also please use an Oxford comma :-)
841febc
to
40e38aa
Compare
@koba04 this needs to be rebased, so as to remove all merge commits; i have some commits i need to add to master first, so i'll rebase this branch for you after that, and then merge it. |
ca9b440
to
d8b83cd
Compare
@ljharb Rebased! But I couldn't run unit tests on my local because
I'm using macOS 10.12.6 and Node v8.9.0 and npm v5.5.1. |
d8b83cd
to
4ab4804
Compare
@koba04 hm, that should definitely work. i'll give it a shot. |
(altho you don't need to run lerna yourself; |
Thanks! To be accurate, that is a result through |
Thanks! |
(I avoided the trouble by |
Is this fixed and already in the latest version? Because I am using 3.3.0 and this problem persists. The workaround for me is to use mount instead of shallow. |
@luissmg Yes, I think so. If you still have an issue, please create an issue with an example to reproduce it. |
@ljharb @lelandrichardson This is to fix #1247 🙏
Currently, componentDidUpdate is not called when calling setState with React v16.