fix(complement-race): resolve infinite render loop in useTrackManagement

Fixed "Maximum update depth exceeded" error by removing displayPassengers
from the effect dependency array. The effect calls setDisplayPassengers,
which was triggering infinite re-renders at 60fps update frequency.

The displayPassengers state is only used for comparison inside the effect,
not as an input that should trigger re-execution.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Thomas Hallock
2025-10-23 06:28:39 -05:00
parent 28fc0a14be
commit 8b4dacdc98

View File

@@ -104,7 +104,9 @@ export function useTrackManagement({
setDisplayPassengers(passengers)
}
// Otherwise, keep displaying old passengers until train resets
}, [passengers, displayPassengers, trainPosition, currentRoute])
// Note: displayPassengers is intentionally NOT in deps to avoid infinite loop
// (it's used for comparison, but we don't need to re-run when it changes)
}, [passengers, trainPosition, currentRoute])
// Generate ties and rails when path is ready
useEffect(() => {