const intervalRef = useRef(null)const resetGame = useCallback(() => {clearInterval(intervalRef.current)}, [])
πΉοΈ Building 'Simple' React Games
18 Mar 2026 β’ π 19 min readWhat I learned refactoring two browser games: grouping state, useReducer, stale closures, timer cleanup, render-time randomisation bugs, and replacing three intervals with one rAF loop.