Skip to content
Back to skills

React

ASecurity

Patterns for using Helios with React. Use when building compositions in a React environment.

  • 124 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 5, 2026
ai-agentsjavascriptjavareactawsperformance

Security analysis

A100/100

Scanned November 5, 2026

npx -y skills add BintzGavin/helios --skill react --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of React?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for React
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/bintzgavin-react/badge)](https://www.skillsdirectory.com/skills/bintzgavin-react)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: example-react
description: Patterns for using Helios with React. Use when building compositions in a React environment.
---

# React Composition Patterns

Integrate Helios into React components using hooks for state management and Refs for canvas access.

## Quick Start

### 1. Create `useVideoFrame` Hook

This hook subscribes to Helios and returns the current frame, triggering re-renders.

```javascript
// hooks/useVideoFrame.js
import { useState, useEffect } from 'react';

export function useVideoFrame(helios) {
  const [frame, setFrame] = useState(helios.currentFrame.peek());

  useEffect(() => {
    // Subscribe to updates
    const unsubscribe = helios.subscribe((state) => {
      setFrame(state.currentFrame);
    });
    return unsubscribe;
  }, [helios]);

  return frame;
}
```

### 2. Create Composition Component

```jsx
// App.jsx
import React, { useRef, useEffect } from 'react';
import { Helios } from '@helios-project/core';
import { useVideoFrame } from './hooks/useVideoFrame';

// Initialize Singleton (outside component to persist across re-renders)
const helios = new Helios({
  duration: 10,
  fps: 30
});
helios.bindToDocumentTimeline();

// Expose for Renderer/Player
if (typeof window !== 'undefined') window.helios = helios;

export default function App() {
  const canvasRef = useRef(null);
  const frame = useVideoFrame(helios);

  useEffect(() => {
    const ctx = canvasRef.current?.getContext('2d');
    if (!ctx) return;

    const { width, height } = canvasRef.current;

    // Clear
    ctx.clearRect(0, 0, width, height);

    // Draw based on frame
    const progress = frame / (helios.duration * helios.fps);
    ctx.fillStyle = '#61dafb';
    ctx.fillRect(progress * width, height / 2 - 50, 100, 100);

  }, [frame]); // Re-run draw when frame changes

  return <canvas ref={canvasRef} width={1920} height={1080} />;
}
```

## Optimization

For complex scenes, avoid React state updates for every frame (which triggers full component re-render). Instead, use a `useRef` to hold the frame and an animation loop, or update the canvas imperatively inside `subscribe`.

### Imperative Pattern (High Performance)

```jsx
useEffect(() => {
  const ctx = canvasRef.current.getContext('2d');

  const unsubscribe = helios.subscribe((state) => {
    // Draw directly without triggering React render
    drawScene(ctx, state.currentFrame);
  });

  return unsubscribe;
}, []);
```

## Source Files

- Example: `examples/react-canvas-animation/`

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.