Skip to content
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

Shallow rendering, setState after setProps calls componentWillReceiveProps #1779

Merged
merged 1 commit into from Aug 21, 2018
Merged

Shallow rendering, setState after setProps calls componentWillReceiveProps #1779

merged 1 commit into from Aug 21, 2018

Conversation

ghost
Copy link

@ghost ghost commented Aug 20, 2018

Fix for #1746

@ljharb
Copy link
Member

ljharb commented Aug 20, 2018

Thanks! I'll rebase this and tweak to use jsx, and then give it a review.

@ghost
Copy link
Author

ghost commented Aug 20, 2018

Thanks for the quick response, @ljharb! Looking forward to review. 😄

@ljharb ljharb changed the title #1746 - Shallow rendering, setState after setProps calls componentWillreceiveProps Shallow rendering, setState after setProps calls componentWillReceiveProps Aug 20, 2018
Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was able to verify that the tests fail without your fix.

@@ -2406,6 +2406,86 @@ describe('shallow', () => {
});
});

describeIf(is('>= 16.3'), 'should not call componentWillReceiveProps after setState is called', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i changed this from is('16.3.0-0') because we want it to apply to v16.4 and later also.

Can you elaborate, though, on why this wouldn't be true for all versions of react?

@ghost
Copy link
Author

ghost commented Aug 21, 2018

@ljharb Thanks for rebasing as well as the additional changes! I initially used describeIf as the test case specified a particular React version, but it's true that the patch does need to apply to all version of React.

I pulled down your changes, fixed describeIf to describe, and I've verified all tests pass with the new changes.

@ljharb ljharb merged commit 1c70681 into enzymejs:master Aug 21, 2018
ljharb added a commit that referenced this pull request Aug 21, 2018
ljharb added a commit that referenced this pull request Aug 25, 2018
 - [New] Add forwardRef support (#1592, @jquense)
 - [New] Add Portal support (#1760, #1761, #1772, #1774, @jgzuke)
 - [New] Add pointer events support (#1753, @ljharb)
 - [Fix] preemptively fix compat with React v16.4.3 (#1790, #1778, @gaearon, @aweary)
 - [Fix] `shallow`: prevent rerenders with PureComponents (#1786, @koba04)
 - [Fix] `shallow`: skip updates when nextState is `null` or `undefined` (#1785, @koba04)
 - [Fix] `shallow`: `setState` after `setProps` calls `componentWillReceiveProps` (#1779, @peanutenthusiast)
 - [Fix] `mount`/`shallow`: be stricter on the wrapper’s setState/setProps callback
 - [Fix] `shallow`/`mount`: improve error message when wrapping invalid elements (#1759, @jgzuke)
 - update deps
 - [Refactor] remove most uses of lodash
 - [meta] ensure a license and readme is present in all packages when published
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants