d/reactjsAahmadAug 10, 2026
useEffect with a ref dependency: is it ever actually safe?

I've seen people put a ref in a useEffect dependency array and pretend it works. My understanding is refs are stable by contract, so it's a no-op — but does that make it safe or just silently wrong? What do you do when an effect needs the latest ref value AND needs to react to other deps?

17
0 comments

Comments (0)