DEV Community

Discussion on: Introduction to useRef Hook

Collapse
 
andyneale profile image
Andy Neale

Great article, a lot of things suddenly make sense to me now!

Just one minor observation - should the effect have the value as a dependency so that it doesn't run on every re-render?

React.useEffect(() => {
  ref.current = value
}, [value])
Collapse
 
dinhhuyams profile image
TrinhDinhHuy • Edited

Yes, it should. Thankss, I updated the article