registerRoot()
registerRoot
is a function that registers the root component of the Remotion project. In the root component, one or multiple compositions should be returned (in the case of multiple compositions, they should be wrapped in a React Fragment).
info
registerRoot()
should live in a file that is separarate from the list of compositions. This is because when using React Fast Refresh, all the code in the file that gets refreshed gets executed again, however, this function should only be called once.
Example
src/index.tstsx
import {registerRoot } from "remotion";import {RemotionVideo } from "./Video";registerRoot (RemotionVideo );
src/index.tstsx
import {registerRoot } from "remotion";import {RemotionVideo } from "./Video";registerRoot (RemotionVideo );
src/Video.tsxtsx
importMyComponent from "./MyComponent";importMyOtherComponent from "./MyOtherComponent";export constRemotionVideo = () => {return (<><Composition id ="comp"fps ={30}height ={1080}width ={1920}component ={MyComponent }/><Composition id ="anothercomp"fps ={30}height ={1080}width ={1920}component ={MyOtherComponent }/></>);};
src/Video.tsxtsx
importMyComponent from "./MyComponent";importMyOtherComponent from "./MyOtherComponent";export constRemotionVideo = () => {return (<><Composition id ="comp"fps ={30}height ={1080}width ={1920}component ={MyComponent }/><Composition id ="anothercomp"fps ={30}height ={1080}width ={1920}component ={MyOtherComponent }/></>);};