🎥 Make videos programmatically with React
allow to add a ref to a sequence as well
Jonny Burgerab810551058f
diff --git a/packages/core/src/Sequence.tsx b/packages/core/src/Sequence.tsxindex 3f46e7a98c..0cdce7e6eb 100644--- a/packages/core/src/Sequence.tsx+++ b/packages/core/src/Sequence.tsx@@ -1,5 +1,6 @@import React, {createContext,+ forwardRef,useContext,useEffect,useMemo,@@ -41,15 +42,21 @@ export type SequenceProps = {showLoopTimesInTimeline?: number;} & LayoutAndStyle;-export const Sequence: React.FC<SequenceProps> = ({- from,- durationInFrames = Infinity,- children,- name,- showInTimeline = true,- showLoopTimesInTimeline,- ...other-}) => {+const SequenceRefForwardingFunction: React.ForwardRefRenderFunction<+ HTMLDivElement,+ SequenceProps+> = (+ {+ from,+ durationInFrames = Infinity,+ children,+ name,+ showInTimeline = true,+ showLoopTimesInTimeline,+ ...other+ },+ ref+) => {const {layout = 'absolute-fill'} = other;const [id] = useState(() => String(Math.random()));const parentSequence = useContext(SequenceContext);@@ -186,13 +193,23 @@ export const Sequence: React.FC<SequenceProps> = ({};}, [styleIfThere]);+ if (ref !== null && layout === 'none') {+ throw new TypeError(+ 'It is not supported to pass both a `ref` and `layout="none"` to <Sequence />.'+ );+ }+return (<SequenceContext.Provider value={contextValue}>{content === null ? null : layout === 'absolute-fill' ? (- <AbsoluteFill style={defaultStyle}>{content}</AbsoluteFill>+ <AbsoluteFill ref={ref} style={defaultStyle}>+ {content}+ </AbsoluteFill>) : (content)}</SequenceContext.Provider>);};++export const Sequence = forwardRef(SequenceRefForwardingFunction);diff --git a/packages/example/src/Freeze/FreezeExample.tsx b/packages/example/src/Freeze/FreezeExample.tsxindex 49e66eec0a..87d52c25da 100644--- a/packages/example/src/Freeze/FreezeExample.tsx+++ b/packages/example/src/Freeze/FreezeExample.tsx@@ -1,5 +1,5 @@import React from 'react';-import {Freeze, Series, staticFile, Video} from 'remotion';+import {Freeze, Sequence, Series, staticFile, Video} from 'remotion';export const FreezeExample: React.FC = () => {const video = staticFile('framermp4withoutfileextension');@@ -8,6 +8,9 @@ export const FreezeExample: React.FC = () => {<Series><Series.Sequence durationInFrames={25}><Freeze frame={0}>+ <Sequence layout="none" from={0}>+ <div>hi</div>+ </Sequence><Video src={video} /></Freeze></Series.Sequence>