Instagram story viewer> @useless_engineer.dev> Post
11 days ago
2
Posted On: October 5th 2026, 02:06 am
P128: setInterval inside useEffect with empty deps runs once — its callback closes over state from that single render. State keeps updating, but the interval callback never sees anything but the value it captured at mount.
setCount(c => c + 1) reads React's current state instead of the closure. Need the latest value for more than setState? Keep a ref in sync and read ref.current.
🔖 save slide 5.
#reactnative #react #typescript #javascript #cleancode
Comments (2)
sayeed.saran 11 days ago

sayeed.saran

informative ❤️

More posts

back to up