inferno: `setState` in `componentWillReceiveProps` triggers `render`
Hi there. While working through a bunch of mini prototypes tonight I spotted a behavior I’m hoping you all can nick. This repro mocks a mini polling connector and consumer setup. The end-consumer updates its state in response to a prop change using the componentWillReceiveProps() lifecycle method. It appears that a setState call in componentWillReceiveProps triggers another render() pass vs coalescing with the existing props update.
I’m hoping that matching React’s component spec is possible. From component lifecycle specs:
Use this as an opportunity to react to a prop transition before render() is called by updating the state using this.setState(). The old props can be accessed via this.props. Calling this.setState() within this function will not trigger an additional render
Environment/runtime information is in #131. An example by way of picture:
console output while updating state in componentWillReceiveProps():

console output without state update:

Thanks again!
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 16 (8 by maintainers)
Commits related to this issue
- fixes #133 — committed to infernojs/inferno by trueadm 8 years ago
- fixes #133 and updates inferno-compat to include Inferno createVNode and createBlueprint — committed to infernojs/inferno by deleted user 8 years ago
@mseeley I think I’ve located the route of this problem. I’ll push a fix for it to
spikelater tonight 😃 thanks for the help!