-
-
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] shallow
: x.find()
should not change state of x
#2061
base: master
Are you sure you want to change the base?
Conversation
…dComponentUpdate` method before updating the wrapper. Fixes enzymejs#1916.
shallow
: x.find()
should not change state of x
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've rebased this.
I suspect we'll need to add shouldComponentUpdate
to all the adapters.
@@ -1785,6 +1785,7 @@ describe('shallow', () => { | |||
const wrapper = shallow(<MyComponent />, { disableLifecycleMethods: true }); | |||
expect(wrapper.find(Table).length).to.equal(0); | |||
wrapper.instance().componentDidMount(); | |||
wrapper.update(); |
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.
the need for this addition concerns me; perhaps that's OK because most people won't be manually calling a lifecycle method, but this makes it seem like it might be a breaking change :-/
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.
@ljharb any idea or prediction on when this could be included in an official release? 👍
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.
finishing this up today
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 dont think we need this if we return true per your comment here: #2061 (comment). Checking though
re > I suspect we'll need to add shouldComponentUpdate to all the adapters. If we have the conditional to check if the shouldUpdateComponent is present why would we need to include it in all adapters? Edit: some tests are failing, going to look into that as well, pushed some changes per your comments. |
@@ -1785,6 +1785,7 @@ describe('shallow', () => { | |||
const wrapper = shallow(<MyComponent />, { disableLifecycleMethods: true }); | |||
expect(wrapper.find(Table).length).to.equal(0); | |||
wrapper.instance().componentDidMount(); | |||
|
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.
@ljharb was able to remove the wrapper.update()
by returning true in the adapter function.
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.
This still seems to be failing.
if (this[ROOT][WRAPPING_COMPONENT]) { | ||
this[ROOT][WRAPPING_COMPONENT].unmount(); | ||
this[ROOT][WRAPPING_COMPONENT].update(); |
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.
Curious why these were added?
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.
to make tests pass; they were failing.
@sstern6 because the issue this fixes should be fixed for all versions of react, not just react 16. |
40cc703
to
0a17404
Compare
Hey guys! Any news on this PR? |
Hi guys, I am also waiting for this PR. Is someone looking into this? |
Do you have plans to release it? It is an important fix that I'm waiting for. |
@sstern6 ping for an update? |
So sorry, didnt get pinged on my email. Yes I will prioritize this week. I sincerely apologize, a lot of personal things going on right now has been hard to see this through. If someone else would like to take it please be my guest. If not, this will be prioritized this week |
I'm also interested in this fix |
hi @sstern6, were you able to work on this? I need this, how can I help? |
Hey again! Sorry for pinging constantly, but are there any news? |
Codecov Report
@@ Coverage Diff @@
## master #2061 +/- ##
==========================================
+ Coverage 96.12% 96.13% +0.01%
==========================================
Files 49 49
Lines 4004 4015 +11
Branches 1123 1127 +4
==========================================
+ Hits 3849 3860 +11
Misses 155 155
Continue to review full report at Codecov.
|
2227326
to
0d5ead7
Compare
43eb75e
to
39e6b1f
Compare
Fixes #1916.