setState call in cWRP prevents correct cDU call
- Dominant language
- JavaScript
- Stars
- 19.8k
- Forks
- 2k
- PR merge metrics
- No merged PRs in 30d
Description
### Current behavior
I have a project at work where calling `shallowWrapper.setProps({...})` doesn't trigger `componentDidUpdate()` if the preceding `componentWillReceiveProps()` invokes `setState({...})`.
I was unable to replicate this in Enzyme's unit tests, but I observed a slightly different bug there: If `componentWillReceiveProps()` calls `setState()`, the subsequent `componentDidUpdate()` receives the same set of props as both `this.props` and `nextProps`. [Test case](https://github.com/TrevorBurnham/enzyme/blob/b2caac31f7b028d9ed35243bac02f284604d7e67/packages/enzyme-test-suite/test/ShallowWrapper-spec.jsx#L3053-L3096)
In both cases, I observe the failure only with the React 16 adapter. With the React 15 adapter, I see the expected behavior.
### Expected behavior
Calling `setState()` in `componentWillReceiveProps()` should have no effect on whether `componentDidUpdate()` is called or what it sees as `this.props`.
### Your environment
#### API
- [x] shallow
#### Version
| library | version
| ------------------- | -------
| enzyme | 3.10.0
| react | 16.8.5
| react-dom | 16.8.5
| react-test-renderer | 16.8.6
| adapter (below) | 1.12.1
#### Adapter
- [x] enzyme-adapter-react-16
Contributor guide
Assessment
This issue has not been assessed yet.