enzymejs/enzyme

setState call in cWRP prevents correct cDU call

Open

#2,191 建立於 2019年7月16日

在 GitHub 查看
 (0 留言) (1 反應) (0 負責人)JavaScript (19,979 star) (2,016 fork)batch import
bughelp wantedpackage: react adapter: 16

描述

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

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

  • 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

  • enzyme-adapter-react-16

貢獻者指南

setState call in cWRP prevents correct cDU call · enzymejs/enzyme#2191 | Good First Issue