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:
@@ -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(() => {
|
||||
|
||||
Reference in New Issue
Block a user