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

Don't call componentDidUpdate() in shallow renderer #10372

Merged
merged 3 commits into from
Aug 3, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions src/renderers/testing/ReactShallowRendererEntry.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,6 @@ class ReactShallowRenderer {
this._instance.state = state;

this._rendered = this._instance.render();

// The 15.x shallow renderer triggered cDU for setState() calls only.
if (
oldState !== state &&
typeof this._instance.componentDidUpdate === 'function'
) {
this._instance.componentDidUpdate(oldProps, oldState);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Might be nice to leave a placeholder comment referencing why we decided not to call cDU

}
}

Expand Down
9 changes: 2 additions & 7 deletions src/renderers/testing/__tests__/ReactShallowRenderer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,7 @@ describe('ReactShallowRenderer', () => {
const instance = shallowRenderer.getMountedInstance();
instance.setState({});

// The previous shallow renderer triggered cDU for setState() calls.
expect(logs).toEqual([
'shouldComponentUpdate',
'componentWillUpdate',
'componentDidUpdate',
]);
expect(logs).toEqual(['shouldComponentUpdate', 'componentWillUpdate']);

logs.splice(0);

Expand Down Expand Up @@ -407,7 +402,7 @@ describe('ReactShallowRenderer', () => {
updatedState,
updatedContext,
]);
expect(componentDidUpdateParams).toEqual([initialProp, initialState]);
expect(componentDidUpdateParams).toEqual([]);
});

it('can shallowly render components with ref as function', () => {
Expand Down