Skip to content

Commit

Permalink
Call getDerivedStateFromProps even for setState of ShallowRenderer (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
koba04 authored and gaearon committed Apr 30, 2018
1 parent 9a9f547 commit 7dd4ca2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 1 addition & 2 deletions packages/react-test-renderer/src/ReactShallowRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,8 @@ class ReactShallowRenderer {
this._instance.UNSAFE_componentWillReceiveProps(props, context);
}
}

this._updateStateFromStaticLifecycle(props);
}
this._updateStateFromStaticLifecycle(props);

// Read state after cWRP in case it calls setState
const state = this._newState || oldState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe('ReactShallowRenderer', () => {
const instance = shallowRenderer.getMountedInstance();
instance.setState({});

expect(logs).toEqual(['shouldComponentUpdate']);
expect(logs).toEqual(['getDerivedStateFromProps', 'shouldComponentUpdate']);

logs.splice(0);

Expand Down

0 comments on commit 7dd4ca2

Please sign in to comment.