Function

useTimelineEvent

Subscribes to a typed TimelineEngine event with a React-safe latest handler.

Usage notes

The hook keeps the event subscription stable while updating the callback ref every render, avoiding stale closures without resubscribing for handler-only changes. Use it for low-level integration work such as analytics, custom status panels, or imperative bridges. Prefer focused hooks such as useTimelinePlayheadTime or useTimelineClipDropFeedback when a public hook already exists for the state you need. Events with `void` payloads can still use zero-argument handlers.

Signature

Type Definition
useTimelineEvent(eventName: EventName, handler: TimelineEventHandler<EventName>, options: TimelineEventOptions = {}): void

Type parameters

NameConstraintDefaultDescription
EventNametypeOperatorNoneTimeline engine event name from `EngineEventMap`.

Parameters

NameTypeDescription
eventNameEventNameTimelineEngine event name to subscribe to.
handlerTimelineEventHandler<EventName>Callback invoked with the typed event payload.
optionsTimelineEventOptionsOptional subscription controls.

Returns

void

Nothing; the subscription is managed for the component lifetime.

Examples

tsx Example
import { useState } from 'react';
import { useTimelineEvent } from '#react/hooks';
export function PlaybackRateReadout() {
const [rate, setRate] = useState(1);
useTimelineEvent('playback:rate', setRate);
return <span>{rate}x</span>;
}