-
Notifications
You must be signed in to change notification settings - Fork 49.8k
Description
Do you want to request a feature or report a bug?
bug
What is the current behavior?
When inside of a forwardRef, calling setState causes componentWillReceiveProps to be called after the setState has completed.
See https://codesandbox.io/s/n59k2v25r0 for demo
What is the expected behavior?
The docs don't seem to forbid this behavior ("Calling this.setState() generally doesn’t trigger UNSAFE_componentWillReceiveProps()."), so I'm not sure this is technically a bug.
However, it does cause older code that doesn't yet use the reducer syntax for setState to stop working when wrapped in forwardRef. It caused a few headscratchers for me while refactoring old code, so I'm reporting it just in case.
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
This appears in 16.3.2. Given that it is specific to forwardRef, it shouldn't apply to older versions.