Fix to prevent updates with PureComponent#1786
Merged
ljharb merged 1 commit intoenzymejs:masterfrom Aug 22, 2018
Merged
Conversation
ljharb
requested changes
Aug 22, 2018
|
|
||
| describeIf(is('>= 15.3'), 'PureComponent', () => { | ||
| it('should not update when state and props did not change', () => { | ||
| class Foo extends React.PureComponent { |
Member
There was a problem hiding this comment.
let's add PureComponent to the react-compat file, and bring it in from there.
| }); | ||
| }); | ||
|
|
||
| describeIf(is('>= 15.3'), 'PureComponent', () => { |
Member
There was a problem hiding this comment.
Let's also add corresponding tests for non-pure components that implement their own shouldComponentUpdate (or flesh out the existing one)
| spy = spyMethod(instance, 'shouldComponentUpdate'); | ||
| // PureComponent | ||
| } else if (instance.isPureReactComponent) { | ||
| shouldRender = !isEqual(prevProps, props) || !isEqual(state, instance.state); |
Member
There was a problem hiding this comment.
let's put this in some sort of pureComponentShouldComponentUpdate function, so here and line 471 can share the implementation.
a70fb05 to
633f5a0
Compare
955a794 to
8ad1015
Compare
4aa56fa to
ec51957
Compare
ljharb
approved these changes
Aug 22, 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
This was referenced Aug 25, 2018
This was referenced Oct 1, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #1784 (comment)