Skip to main content
This example demonstrates how to build a Helios composition using React. It showcases React-specific patterns including custom hooks for frame synchronization and JSX-based rendering.

Setup

Install Helios core and React dependencies:

Implementation

Custom hook for frame synchronization

Create a custom hook to subscribe to Helios frame updates:
The hook uses React’s useState to track the current frame and useEffect to manage the subscription lifecycle. The cleanup function automatically unsubscribes when the component unmounts.

Main component

Build your composition using JSX and the useVideoFrame hook:

Key React patterns

Hook-based state management

The useVideoFrame hook encapsulates Helios subscription logic and provides a clean React-style API. It automatically handles cleanup through the useEffect return function.

Inline styles for dynamic animations

Calculate animation values in the component body and apply them via inline styles. This approach works well for frame-by-frame animations where values change on every render.

Frame-based calculations

Convert frames to progress values, opacity, scale, and rotation using simple math. Each render cycle receives a new frame number, triggering recalculation of all animation values.

Usage

Run the development server:
The composition will render with live frame updates. The Helios instance is exposed on window.helios for debugging and player control.