example-react
Skill130 starsChanged 38 days agoApache-2.0View on GitHub
Patterns for using Helios with React. Use when building compositions in a React environment.
In this repository38 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .github/copilot-instructions.mdCopilot instructions
- llms.txtllms.txt
- skill-creatorSkill
- helios-coreSkill
- animated-video-philosophySkill
- cinematic-product-promo-planSkill
- motion-stylesSkill
- example-canvasSkill
- example-chartjsSkill
- example-d3-animationSkill
- example-framer-motionSkill
- example-gsapSkill
- example-lottieSkill
- example-p5-animationSkill
- example-pixiSkill
- example-podcast-visualizerSkill
- example-signals-animationSkill
- example-solidSkill
- example-svelteSkill
- example-tailwind-animationSkill
- example-threejsSkill
- example-vanillaSkill
- example-vueSkill
- helios-getting-startedSkill
- guided-brand-videoSkill
- guided-cartoon-shortSkill
- motion-design-rulesSkill
- guided-music-videoSkill
- guided-video-recipesSkill
- helios-playerSkill
- helios-rendererSkill
- helios-skillsSkill
- helios-studioSkill
- archive-brollSkill
- create-compositionSkill
- render-videoSkill
- workflow-visualize-dataSkill
The file
Files
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.
// 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
// 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)
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/
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

