Description
In ForgeMode.jsx, there are missing dependencies in two useEffect hooks. This triggers ESLint warnings (react-hooks/exhaustive-deps) and creates the risk of state desynchronization. If the component re-renders, these effects may operate on stale closures (outdated state values), potentially causing the timer to malfunction or the audio stream to ignore volume/mute changes.
ESLint Warnings
Running npm run lint in the frontend directory outputs the following:
- Line 135:
React Hook useEffect has a missing dependency: 'handleTimerComplete'.
- Line 157:
React Hook useEffect has missing dependencies: 'isMuted', 'isRunning', and 'volume'.
Expected Behavior
All reactive variables referenced inside useEffect hooks should be properly tracked in the dependency array to ensure the effect always captures the latest state.
Proposed Solution
- Timer Effect: Wrap the
handleTimerComplete function in a useCallback hook and safely add it to the dependency array of the interval effect.
- Audio Stream Effect: Refactor the audio initialization effect. Currently, it tries to access
isMuted, volume, and isRunning without tracking them. We should either add these to the dependency array and properly manage re-instantiation, or remove them from this specific hook entirely since there are already separate hooks below it that handle syncing volume, muting, and playing/pausing.
Description
In
ForgeMode.jsx, there are missing dependencies in twouseEffecthooks. This triggers ESLint warnings (react-hooks/exhaustive-deps) and creates the risk of state desynchronization. If the component re-renders, these effects may operate on stale closures (outdated state values), potentially causing the timer to malfunction or the audio stream to ignore volume/mute changes.ESLint Warnings
Running
npm run lintin thefrontenddirectory outputs the following:React Hook useEffect has a missing dependency: 'handleTimerComplete'.React Hook useEffect has missing dependencies: 'isMuted', 'isRunning', and 'volume'.Expected Behavior
All reactive variables referenced inside
useEffecthooks should be properly tracked in the dependency array to ensure the effect always captures the latest state.Proposed Solution
handleTimerCompletefunction in auseCallbackhook and safely add it to the dependency array of the interval effect.isMuted,volume, andisRunningwithout tracking them. We should either add these to the dependency array and properly manage re-instantiation, or remove them from this specific hook entirely since there are already separate hooks below it that handle syncing volume, muting, and playing/pausing.