Do you want to request a feature or report a bug?
Feature
What is the current behavior?
There are no warnings when assigning to ref.current in render phase.
What is the expected behavior?
Given that this mostly works now, but may cause issues on release of concurrent mode, it would be helpful to have a warning when assigning to a prop outside of useEffect().
E.g. I recently wrote this code, which works fine at the moment, and didn't realize the possible issue until @gaearon pointed out the missing useEffect():
export function useDidChange(value) {
let ref = useRef()
let didChange = ref.current !== value
ref.current = value
return didChange
}
If a warning is not possible due to the lazy initialization pattern, perhaps an eslint rule may be a solution?
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
All versions
Do you want to request a feature or report a bug?
Feature
What is the current behavior?
There are no warnings when assigning to
ref.currentin render phase.What is the expected behavior?
Given that this mostly works now, but may cause issues on release of concurrent mode, it would be helpful to have a warning when assigning to a prop outside of
useEffect().E.g. I recently wrote this code, which works fine at the moment, and didn't realize the possible issue until @gaearon pointed out the missing
useEffect():If a warning is not possible due to the lazy initialization pattern, perhaps an eslint rule may be a solution?
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
All versions