useFlightPhase subscribes to flight phase changes via Socket.io and keeps the TanStack Query cache in sync. It only re-renders when the phase actually changes — not on every simulator data tick.
On mount it hydrates from GET /api/simulator/flight-phase/snapshot, then listens for flight:phase Socket.io events.
Import
Signature
Parameters
| Parameter | Type | Description |
|---|---|---|
options.select | (snapshot: FlightPhaseSnapshot) => TSelected | Selector function. The component only re-renders when the selected value changes. |
FlightPhaseSnapshot
FlightPhase enum
GO_AROUND, REJECTED_TAKE_OFF) can interrupt this sequence.
Usage
Selector pattern
Subscribe only to the current phase string — the component will not re-render ontrends or pendingTransition changes:
Detecting phase transitions
Notes
- The hook uses
staleTime: Infinity— Socket.io pushes are the sole update mechanism after the initial REST hydration. There is no polling. - Phase transitions have built-in debounce delays in the flight state manager to prevent rapid flapping.
- If you need the full tracking session state (isTracking, elapsedTime, etc.), use
useTrackingSessioninstead.