You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The fact that refs are called on any updates is expected if you pass an arrow function. I explained why here: #9328 (comment). It is also mentioned in the ref documentation.
The infinite loop itself sounds somewhat expected to me too. You can use ref callbacks for setting fields or setting/clearing native event subscriptions. But unconditionally scheduling additional updates from them sounds like a problem with your code, just like calling forceUpdate in componentDidUpdate would be. What problem are you trying to solve?
I don't think I understand the problem from this description. But if your ref callback does anything other than setting a field, it's probably the wrong place to do that.
Do you want to request a feature or report a bug?
Bug, maybe
What is the current behavior?
On calling forceUpdate ref callbacks called again. So, doing forceUpdate in ref callback makes infinite loop.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://jsfiddle.net or similar (template for React 16: https://jsfiddle.net/Luktwrdm/, template for React 15: https://jsfiddle.net/hmbg7e9w/).
https://codepen.io/TrySound/pen/mqKqeB?editors=0012
What is the expected behavior?
Do not recall refs
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
react 16.1.1
chrome 62
The text was updated successfully, but these errors were encountered: