Skip to content

🎥 Make videos programmatically with React

Remove obsolete Interactive ref forwarding

JonnyBurger83ce7a8ab0bd
diff --git a/packages/brand/src/3DContext/Div3D.tsx b/packages/brand/src/3DContext/Div3D.tsx
index 90ec726fdf..e91ab96f1e 100644
--- a/packages/brand/src/3DContext/Div3D.tsx
+++ b/packages/brand/src/3DContext/Div3D.tsx
@@ -373,161 +373,154 @@ const getTransformStyle = ({
});
};
-const ExtrudeDivInner = React.forwardRef<
- HTMLDivElement,
+const ExtrudeDivInner: React.FC<
ExtrudeDivProps & {
readonly controls: SequenceControls | undefined;
}
->(
- (
- {
- children,
- width = 200,
- height = 100,
- depth = 40,
- cornerRadius = 0,
- backFace,
- style,
- translationX = 0,
- translationY = 0,
- translationZ = 0,
- rotationX = 0,
- rotationY = 0,
- rotationZ = 0,
- scaleX = 1,
- scaleY = 1,
- scaleZ = 1,
- topFace,
- bottomFace,
- durationInFrames,
- from,
- trimBefore,
- trimAfter,
- loop,
- freeze,
- hidden,
- name,
- showInTimeline,
- controls,
- },
- ref,
- ) => {
- const parentTransform = useTransformations();
- const parentCenterPoint = React.useContext(CenterPointContext);
- const localTranslate = style?.translate;
- const localScale = style?.scale;
- const localRotate = style?.rotate;
- const localTransformOrigin = style?.transformOrigin;
- const localTransform = React.useMemo(() => {
- return getTransformStyle({
- height,
- rotate: localRotate,
- rotationX,
- rotationY,
- rotationZ,
- scale: localScale,
- scaleX,
- scaleY,
- scaleZ,
- transformOrigin: localTransformOrigin,
- translate: localTranslate,
- translationX,
- translationY,
- translationZ,
- width,
- });
- }, [
+> = ({
+ children,
+ width = 200,
+ height = 100,
+ depth = 40,
+ cornerRadius = 0,
+ backFace,
+ style,
+ translationX = 0,
+ translationY = 0,
+ translationZ = 0,
+ rotationX = 0,
+ rotationY = 0,
+ rotationZ = 0,
+ scaleX = 1,
+ scaleY = 1,
+ scaleZ = 1,
+ topFace,
+ bottomFace,
+ durationInFrames,
+ from,
+ trimBefore,
+ trimAfter,
+ loop,
+ freeze,
+ hidden,
+ name,
+ showInTimeline,
+ controls,
+}) => {
+ const parentTransform = useTransformations();
+ const parentCenterPoint = React.useContext(CenterPointContext);
+ const localTranslate = style?.translate;
+ const localScale = style?.scale;
+ const localRotate = style?.rotate;
+ const localTransformOrigin = style?.transformOrigin;
+ const localTransform = React.useMemo(() => {
+ return getTransformStyle({
height,
- localRotate,
- localScale,
- localTransformOrigin,
- localTranslate,
+ rotate: localRotate,
rotationX,
rotationY,
rotationZ,
+ scale: localScale,
scaleX,
scaleY,
scaleZ,
+ transformOrigin: localTransformOrigin,
+ translate: localTranslate,
translationX,
translationY,
translationZ,
width,
- ]);
- const combinedTransform = React.useMemo(() => {
- return reduceMatrices([parentTransform, localTransform]);
- }, [localTransform, parentTransform]);
- const combinedCenterPoint = React.useMemo(() => {
- return transformPoint({matrix: localTransform, point: parentCenterPoint});
- }, [localTransform, parentCenterPoint]);
- const frontFace = isBacksideVisible(combinedTransform);
-
- return (
- <Sequence
- layout="none"
- from={from ?? 0}
- trimBefore={trimBefore}
- trimAfter={trimAfter}
- loop={loop}
- durationInFrames={durationInFrames ?? Infinity}
- freeze={freeze}
- hidden={hidden}
- name={name ?? '<ExtrudeDiv>'}
- showInTimeline={showInTimeline ?? true}
- controls={controls ?? undefined}
- _remotionInternalDocumentationLink="https://www.remotion.dev/docs/studio/make-component-interactive"
- >
- <TransformContext.Provider value={combinedTransform}>
- <CenterPointContext.Provider value={combinedCenterPoint}>
- <RectProvider
- height={height}
- width={width}
- cornerRadius={cornerRadius}
+ });
+ }, [
+ height,
+ localRotate,
+ localScale,
+ localTransformOrigin,
+ localTranslate,
+ rotationX,
+ rotationY,
+ rotationZ,
+ scaleX,
+ scaleY,
+ scaleZ,
+ translationX,
+ translationY,
+ translationZ,
+ width,
+ ]);
+ const combinedTransform = React.useMemo(() => {
+ return reduceMatrices([parentTransform, localTransform]);
+ }, [localTransform, parentTransform]);
+ const combinedCenterPoint = React.useMemo(() => {
+ return transformPoint({matrix: localTransform, point: parentCenterPoint});
+ }, [localTransform, parentCenterPoint]);
+ const frontFace = isBacksideVisible(combinedTransform);
+
+ return (
+ <Sequence
+ layout="none"
+ from={from ?? 0}
+ trimBefore={trimBefore}
+ trimAfter={trimAfter}
+ loop={loop}
+ durationInFrames={durationInFrames ?? Infinity}
+ freeze={freeze}
+ hidden={hidden}
+ name={name ?? '<ExtrudeDiv>'}
+ showInTimeline={showInTimeline ?? true}
+ controls={controls ?? undefined}
+ _remotionInternalDocumentationLink="https://www.remotion.dev/docs/studio/make-component-interactive"
+ >
+ <TransformContext.Provider value={combinedTransform}>
+ <CenterPointContext.Provider value={combinedCenterPoint}>
+ <RectProvider
+ height={height}
+ width={width}
+ cornerRadius={cornerRadius}
+ >
+ <div
+ style={{
+ ...style,
+ width,
+ height,
+ position: 'relative',
+ transform:
+ depth === 0
+ ? makeMatrix3dTransform(combinedTransform)
+ : undefined,
+ transformOrigin: undefined,
+ translate: undefined,
+ rotate: undefined,
+ scale: undefined,
+ }}
>
- <div
- ref={ref}
- style={{
- ...style,
- width,
- height,
- position: 'relative',
- transform:
- depth === 0
- ? makeMatrix3dTransform(combinedTransform)
- : undefined,
- transformOrigin: undefined,
- translate: undefined,
- rotate: undefined,
- scale: undefined,
- }}
- >
- {depth > 0 ? <DivExtrusion depth={depth} /> : children}
- {depth === 0 ? null : !frontFace ? (
- <Face type="front" depth={depth}>
- {children}
- </Face>
- ) : (
- <Face type="back" depth={depth}>
- {backFace}
- </Face>
- )}
- {topFace ? (
- <TopSide depth={depth} width={width} height={height}>
- {topFace}
- </TopSide>
- ) : null}
- {bottomFace ? (
- <BottomSide depth={depth} width={width} height={height}>
- {bottomFace}
- </BottomSide>
- ) : null}
- </div>
- </RectProvider>
- </CenterPointContext.Provider>
- </TransformContext.Provider>
- </Sequence>
- );
- },
-);
+ {depth > 0 ? <DivExtrusion depth={depth} /> : children}
+ {depth === 0 ? null : !frontFace ? (
+ <Face type="front" depth={depth}>
+ {children}
+ </Face>
+ ) : (
+ <Face type="back" depth={depth}>
+ {backFace}
+ </Face>
+ )}
+ {topFace ? (
+ <TopSide depth={depth} width={width} height={height}>
+ {topFace}
+ </TopSide>
+ ) : null}
+ {bottomFace ? (
+ <BottomSide depth={depth} width={width} height={height}>
+ {bottomFace}
+ </BottomSide>
+ ) : null}
+ </div>
+ </RectProvider>
+ </CenterPointContext.Provider>
+ </TransformContext.Provider>
+ </Sequence>
+ );
+};
ExtrudeDivInner.displayName = '<ExtrudeDiv>';
diff --git a/packages/brand/src/3DContext/transformation-context.tsx b/packages/brand/src/3DContext/transformation-context.tsx
index 6f1172a479..1440c5d719 100644
--- a/packages/brand/src/3DContext/transformation-context.tsx
+++ b/packages/brand/src/3DContext/transformation-context.tsx
@@ -127,45 +127,43 @@ const make3DTransform = <ValueKey extends string>({
[valueKey]: schemaField,
} as const satisfies InteractivitySchema;
- const Inner = React.forwardRef<never, TransformInnerProps<ValueKey>>(
- (rawProps, _ref) => {
- const props = rawProps as TransformInnerProps<ValueKey>;
- const {
- children,
- durationInFrames,
- from,
- trimBefore,
- trimAfter,
- loop,
- freeze,
- hidden,
- name,
- showInTimeline,
- controls,
- } = props;
- const value = props[valueKey] ?? defaultValue;
- const transform = useMemo(() => makeTransform(value), [value]);
+ const Inner: React.FC<TransformInnerProps<ValueKey>> = (rawProps) => {
+ const props = rawProps as TransformInnerProps<ValueKey>;
+ const {
+ children,
+ durationInFrames,
+ from,
+ trimBefore,
+ trimAfter,
+ loop,
+ freeze,
+ hidden,
+ name,
+ showInTimeline,
+ controls,
+ } = props;
+ const value = props[valueKey] ?? defaultValue;
+ const transform = useMemo(() => makeTransform(value), [value]);
- return (
- <Sequence
- layout="none"
- from={from ?? 0}
- trimBefore={trimBefore}
- trimAfter={trimAfter}
- loop={loop}
- durationInFrames={durationInFrames ?? Infinity}
- freeze={freeze}
- hidden={hidden}
- name={name ?? componentName}
- showInTimeline={showInTimeline ?? true}
- controls={controls ?? undefined}
- _remotionInternalDocumentationLink={transformDocumentationLink}
- >
- <NewTransform transform={transform}>{children}</NewTransform>
- </Sequence>
- );
- },
- );
+ return (
+ <Sequence
+ layout="none"
+ from={from ?? 0}
+ trimBefore={trimBefore}
+ trimAfter={trimAfter}
+ loop={loop}
+ durationInFrames={durationInFrames ?? Infinity}
+ freeze={freeze}
+ hidden={hidden}
+ name={name ?? componentName}
+ showInTimeline={showInTimeline ?? true}
+ controls={controls ?? undefined}
+ _remotionInternalDocumentationLink={transformDocumentationLink}
+ >
+ <NewTransform transform={transform}>{children}</NewTransform>
+ </Sequence>
+ );
+ };
Inner.displayName = componentName;
diff --git a/packages/brand/src/Compose/WhatIsRemotion.tsx b/packages/brand/src/Compose/WhatIsRemotion.tsx
index c93e40a321..5843c139ad 100644
--- a/packages/brand/src/Compose/WhatIsRemotion.tsx
+++ b/packages/brand/src/Compose/WhatIsRemotion.tsx
@@ -51,84 +51,60 @@ const labelSchema = {
},
} as const satisfies InteractivitySchema;
-const setRef = <ElementType,>(
- ref: React.ForwardedRef<ElementType>,
- value: ElementType | null,
-) => {
- if (typeof ref === 'function') {
- ref(value);
- } else if (ref) {
- ref.current = value;
- }
-};
-
-const LabelInner = React.forwardRef<
- HTMLDivElement,
+const LabelInner: React.FC<
LabelProps & {
readonly controls: SequenceControls | undefined;
}
->(
- (
- {
- children,
- durationInFrames,
- from,
- trimBefore,
- trimAfter,
- loop,
- freeze,
- hidden,
- name,
- showInTimeline,
- controls,
- style,
- },
- ref,
- ) => {
- const opacity = useLabelOpacity();
- const callbackRef = React.useCallback(
- (element: HTMLDivElement | null) => {
- setRef(ref, element);
- },
- [ref],
- );
+> = ({
+ children,
+ durationInFrames,
+ from,
+ trimBefore,
+ trimAfter,
+ loop,
+ freeze,
+ hidden,
+ name,
+ showInTimeline,
+ controls,
+ style,
+}) => {
+ const opacity = useLabelOpacity();
- return (
- <Sequence
- layout="none"
- from={from ?? 0}
- trimBefore={trimBefore}
- trimAfter={trimAfter}
- loop={loop}
- durationInFrames={durationInFrames ?? Infinity}
- freeze={freeze}
- hidden={hidden}
- name={name ?? '<Label>'}
- showInTimeline={showInTimeline ?? true}
- controls={controls ?? undefined}
- _remotionInternalDocumentationLink="https://www.remotion.dev/docs/studio/make-component-interactive"
+ return (
+ <Sequence
+ layout="none"
+ from={from ?? 0}
+ trimBefore={trimBefore}
+ trimAfter={trimAfter}
+ loop={loop}
+ durationInFrames={durationInFrames ?? Infinity}
+ freeze={freeze}
+ hidden={hidden}
+ name={name ?? '<Label>'}
+ showInTimeline={showInTimeline ?? true}
+ controls={controls ?? undefined}
+ _remotionInternalDocumentationLink="https://www.remotion.dev/docs/studio/make-component-interactive"
+ >
+ <div
+ className="text-white "
+ style={{
+ fontFamily: 'GT Planar',
+ height: '100%',
+ display: 'flex',
+ flexDirection: 'column',
+ justifyContent: 'center',
+ paddingLeft: 20,
+ fontSize: 24,
+ opacity,
+ ...style,
+ }}
>
- <div
- ref={callbackRef}
- className="text-white "
- style={{
- fontFamily: 'GT Planar',
- height: '100%',
- display: 'flex',
- flexDirection: 'column',
- justifyContent: 'center',
- paddingLeft: 20,
- fontSize: 24,
- opacity,
- ...style,
- }}
- >
- {children}
- </div>
- </Sequence>
- );
- },
-);
+ {children}
+ </div>
+ </Sequence>
+ );
+};
LabelInner.displayName = '<Label>';
diff --git a/packages/brand/src/video-elements/Studio.tsx b/packages/brand/src/video-elements/Studio.tsx
index 4db15aab55..62891a4510 100644
--- a/packages/brand/src/video-elements/Studio.tsx
+++ b/packages/brand/src/video-elements/Studio.tsx
@@ -1635,206 +1635,192 @@ const Timeline: React.FC<{
);
};
-const StudioInner = React.forwardRef<
- HTMLDivElement,
+const StudioInner: React.FC<
StudioProps & {readonly controls: SequenceControls | undefined}
->(
- (
+> = ({
+ compositionName,
+ compositionWidth,
+ compositionHeight,
+ content,
+ controls,
+ durationInFrames,
+ from,
+ freeze,
+ frame,
+ hidden,
+ name,
+ responsivenessProgress,
+ showInTimeline,
+ showTimelineZoom,
+ timelineOffset,
+ trimAfter,
+ trimBefore,
+ loop,
+ viewportHeight,
+ viewportWidth,
+}) => {
+ const {height: videoHeight, fps} = useVideoConfig();
+ const height = viewportHeight ?? videoHeight;
+ const width = viewportWidth;
+ const topPanelHeight = Math.round(
+ (height - MENU_HEIGHT - SPLITTER_SIZE) * TOP_PANEL_RATIO,
+ );
+ const timelineHeight = height - MENU_HEIGHT - topPanelHeight - SPLITTER_SIZE;
+ const canvasRowHeight = topPanelHeight - PREVIEW_TOOLBAR_HEIGHT;
+ const leftSidebarWidth = Math.min(
+ 350,
+ Math.round(width * LEFT_SIDEBAR_RATIO),
+ );
+ const rightSidebarWidth = Math.min(
+ 350,
+ Math.max(250, Math.round(width * RIGHT_SIDEBAR_RATIO)),
+ );
+ const sidebarProgress = interpolate(
+ responsivenessProgress,
+ [0, 0.2],
+ [0, 1],
{
- compositionName,
- compositionWidth,
- compositionHeight,
- content,
- controls,
- durationInFrames,
- from,
- freeze,
- frame,
- hidden,
- name,
- responsivenessProgress,
- showInTimeline,
- showTimelineZoom,
- timelineOffset,
- trimAfter,
- trimBefore,
- loop,
- viewportHeight,
- viewportWidth,
+ extrapolateLeft: 'clamp',
+ extrapolateRight: 'clamp',
},
- ref,
- ) => {
- const elementRef = React.useRef<HTMLDivElement>(null);
- React.useImperativeHandle(
- ref,
- () => elementRef.current as HTMLDivElement,
- [],
- );
- const {height: videoHeight, fps} = useVideoConfig();
- const height = viewportHeight ?? videoHeight;
- const width = viewportWidth;
- const topPanelHeight = Math.round(
- (height - MENU_HEIGHT - SPLITTER_SIZE) * TOP_PANEL_RATIO,
- );
- const timelineHeight =
- height - MENU_HEIGHT - topPanelHeight - SPLITTER_SIZE;
- const canvasRowHeight = topPanelHeight - PREVIEW_TOOLBAR_HEIGHT;
- const leftSidebarWidth = Math.min(
- 350,
- Math.round(width * LEFT_SIDEBAR_RATIO),
- );
- const rightSidebarWidth = Math.min(
- 350,
- Math.max(250, Math.round(width * RIGHT_SIDEBAR_RATIO)),
- );
- const sidebarProgress = interpolate(
- responsivenessProgress,
- [0, 0.2],
- [0, 1],
- {
- extrapolateLeft: 'clamp',
- extrapolateRight: 'clamp',
- },
- );
- const leftSidebarOccupiedWidth =
- (leftSidebarWidth + SPLITTER_SIZE) * (1 - sidebarProgress);
- const rightSidebarOccupiedWidth =
- (rightSidebarWidth + SPLITTER_SIZE) * (1 - sidebarProgress);
- const canvasWidth = Math.max(
- 17,
- width - leftSidebarOccupiedWidth - rightSidebarOccupiedWidth,
- );
+ );
+ const leftSidebarOccupiedWidth =
+ (leftSidebarWidth + SPLITTER_SIZE) * (1 - sidebarProgress);
+ const rightSidebarOccupiedWidth =
+ (rightSidebarWidth + SPLITTER_SIZE) * (1 - sidebarProgress);
+ const canvasWidth = Math.max(
+ 17,
+ width - leftSidebarOccupiedWidth - rightSidebarOccupiedWidth,
+ );
- return (
- <Sequence
- controls={controls}
- durationInFrames={durationInFrames}
- freeze={freeze}
- from={from ?? 0}
- hidden={hidden}
- layout="none"
- name={name ?? '<Studio>'}
- showInTimeline={showInTimeline ?? true}
- trimAfter={trimAfter}
- trimBefore={trimBefore}
- loop={loop}
+ return (
+ <Sequence
+ controls={controls}
+ durationInFrames={durationInFrames}
+ freeze={freeze}
+ from={from ?? 0}
+ hidden={hidden}
+ layout="none"
+ name={name ?? '<Studio>'}
+ showInTimeline={showInTimeline ?? true}
+ trimAfter={trimAfter}
+ trimBefore={trimBefore}
+ loop={loop}
+ >
+ <div
+ style={{
+ backgroundColor: BACKGROUND,
+ color: WHITE,
+ display: 'flex',
+ flexDirection: 'column',
+ fontFamily: 'Arial, Helvetica, sans-serif',
+ fontSize: 13,
+ fontWeight: 400,
+ height,
+ left: 0,
+ lineHeight: 1.5,
+ overflow: 'hidden',
+ position: 'absolute',
+ top: 0,
+ width,
+ }}
>
- <div
- ref={elementRef}
- style={{
- backgroundColor: BACKGROUND,
- color: WHITE,
- display: 'flex',
- flexDirection: 'column',
- fontFamily: 'Arial, Helvetica, sans-serif',
- fontSize: 13,
- fontWeight: 400,
- height,
- left: 0,
- lineHeight: 1.5,
- overflow: 'hidden',
- position: 'absolute',
- top: 0,
- width,
- }}
- >
- <MenuToolbar
- compositionName={compositionName}
- responsivenessProgress={responsivenessProgress}
- />
- <div style={{height: topPanelHeight, width}}>
- <div style={{display: 'flex', height: canvasRowHeight, width}}>
+ <MenuToolbar
+ compositionName={compositionName}
+ responsivenessProgress={responsivenessProgress}
+ />
+ <div style={{height: topPanelHeight, width}}>
+ <div style={{display: 'flex', height: canvasRowHeight, width}}>
+ <div
+ style={{
+ flexShrink: 0,
+ height: canvasRowHeight,
+ overflow: 'hidden',
+ position: 'relative',
+ width: leftSidebarOccupiedWidth,
+ }}
+ >
<div
style={{
- flexShrink: 0,
+ display: 'flex',
height: canvasRowHeight,
- overflow: 'hidden',
- position: 'relative',
- width: leftSidebarOccupiedWidth,
+ left: 0,
+ position: 'absolute',
+ translate: `${-sidebarProgress * (leftSidebarWidth + SPLITTER_SIZE)}px 0px`,
+ width: leftSidebarWidth + SPLITTER_SIZE,
}}
>
- <div
- style={{
- display: 'flex',
- height: canvasRowHeight,
- left: 0,
- position: 'absolute',
- translate: `${-sidebarProgress * (leftSidebarWidth + SPLITTER_SIZE)}px 0px`,
- width: leftSidebarWidth + SPLITTER_SIZE,
- }}
- >
- <div style={{width: leftSidebarWidth}}>
- <LeftSidebar />
- </div>
- <Interactive.Div
- name="Left sidebar splitter"
- style={{backgroundColor: SPLITTER, width: SPLITTER_SIZE}}
- />
+ <div style={{width: leftSidebarWidth}}>
+ <LeftSidebar />
</div>
+ <Interactive.Div
+ name="Left sidebar splitter"
+ style={{backgroundColor: SPLITTER, width: SPLITTER_SIZE}}
+ />
</div>
- <PreviewCanvas
- canvasHeight={canvasRowHeight}
- canvasWidth={canvasWidth}
- compositionHeight={compositionHeight}
- compositionWidth={compositionWidth}
- content={content}
- durationInFrames={durationInFrames}
- frame={frame}
- />
+ </div>
+ <PreviewCanvas
+ canvasHeight={canvasRowHeight}
+ canvasWidth={canvasWidth}
+ compositionHeight={compositionHeight}
+ compositionWidth={compositionWidth}
+ content={content}
+ durationInFrames={durationInFrames}
+ frame={frame}
+ />
+ <div
+ style={{
+ flexShrink: 0,
+ height: canvasRowHeight,
+ overflow: 'hidden',
+ position: 'relative',
+ width: rightSidebarOccupiedWidth,
+ }}
+ >
<div
style={{
- flexShrink: 0,
+ display: 'flex',
height: canvasRowHeight,
- overflow: 'hidden',
- position: 'relative',
- width: rightSidebarOccupiedWidth,
+ left: 0,
+ position: 'absolute',
+ width: rightSidebarWidth + SPLITTER_SIZE,
}}
>
- <div
- style={{
- display: 'flex',
- height: canvasRowHeight,
- left: 0,
- position: 'absolute',
- width: rightSidebarWidth + SPLITTER_SIZE,
- }}
- >
- <Interactive.Div
- name="Right sidebar splitter"
- style={{backgroundColor: SPLITTER, width: SPLITTER_SIZE}}
+ <Interactive.Div
+ name="Right sidebar splitter"
+ style={{backgroundColor: SPLITTER, width: SPLITTER_SIZE}}
+ />
+ <div style={{width: rightSidebarWidth}}>
+ <RightSidebar
+ compositionHeight={compositionHeight}
+ compositionName={compositionName}
+ compositionWidth={compositionWidth}
+ durationInFrames={durationInFrames}
+ fps={fps}
/>
- <div style={{width: rightSidebarWidth}}>
- <RightSidebar
- compositionHeight={compositionHeight}
- compositionName={compositionName}
- compositionWidth={compositionWidth}
- durationInFrames={durationInFrames}
- fps={fps}
- />
- </div>
</div>
</div>
</div>
- <PreviewToolbar responsivenessProgress={responsivenessProgress} />
</div>
- <Interactive.Div
- name="Timeline splitter"
- style={{backgroundColor: SPLITTER, height: SPLITTER_SIZE, width}}
- />
- <Timeline
- durationInFrames={durationInFrames}
- fps={fps}
- frame={frame}
- height={timelineHeight}
- showZoom={showTimelineZoom}
- timelineOffset={timelineOffset}
- width={width}
- />
+ <PreviewToolbar responsivenessProgress={responsivenessProgress} />
</div>
- </Sequence>
- );
- },
-);
+ <Interactive.Div
+ name="Timeline splitter"
+ style={{backgroundColor: SPLITTER, height: SPLITTER_SIZE, width}}
+ />
+ <Timeline
+ durationInFrames={durationInFrames}
+ fps={fps}
+ frame={frame}
+ height={timelineHeight}
+ showZoom={showTimelineZoom}
+ timelineOffset={timelineOffset}
+ width={width}
+ />
+ </div>
+ </Sequence>
+ );
+};
StudioInner.displayName = '<Studio>';
diff --git a/packages/codemods/src/basic-captions-element-source.ts b/packages/codemods/src/basic-captions-element-source.ts
index 5112446412..9a1ade51c0 100644
--- a/packages/codemods/src/basic-captions-element-source.ts
+++ b/packages/codemods/src/basic-captions-element-source.ts
@@ -2,7 +2,7 @@ import {parseAst} from './sequence-props/parse-ast';
export const basicCaptionsElementSource = `import type {Caption} from '@remotion/captions';
import {createTikTokStyleCaptions} from '@remotion/captions';
-import React, {forwardRef, useImperativeHandle, useMemo, useRef} from 'react';
+import React, {useMemo} from 'react';
import {
Interactive,
Sequence,
@@ -106,66 +106,56 @@ const basicCaptionsSchema = {
...Interactive.transformSchema,
} as const satisfies InteractivitySchema;
-const BasicCaptionsInner = forwardRef<
- HTMLDivElement,
+const BasicCaptionsInner: React.FC<
BasicCaptionsProps & {readonly controls: SequenceControls | undefined}
->(
- (
- {
- captions,
- combineTokensWithinMilliseconds = 2000,
- controls,
- durationInFrames,
- from,
- height = 220,
- name,
- playbackRate = 1,
- style,
- trimBefore,
- width = 900,
- ...interactiveProps
- },
- ref,
- ) => {
- const elementRef = useRef<HTMLDivElement>(null);
- useImperativeHandle(ref, () => elementRef.current as HTMLDivElement, []);
-
- return (
- <Sequence
- layout="none"
- {...interactiveProps}
- controls={controls}
- name={name ?? 'Basic captions'}
- from={from}
- durationInFrames={durationInFrames}
- trimBefore={trimBefore}
+> = ({
+ captions,
+ combineTokensWithinMilliseconds = 2000,
+ controls,
+ durationInFrames,
+ from,
+ height = 220,
+ name,
+ playbackRate = 1,
+ style,
+ trimBefore,
+ width = 900,
+ ...interactiveProps
+}) => {
+ return (
+ <Sequence
+ layout="none"
+ {...interactiveProps}
+ controls={controls}
+ name={name ?? 'Basic captions'}
+ from={from}
+ durationInFrames={durationInFrames}
+ trimBefore={trimBefore}
+ >
+ <div
+ style={{
+ alignItems: 'center',
+ display: 'flex',
+ justifyContent: 'center',
+ position: 'absolute',
+ bottom: 120,
+ left: '50%',
+ transform: 'translateX(-50%)',
+ width,
+ height,
+ ...style,
+ }}
>
- <div
- ref={elementRef}
- style={{
- alignItems: 'center',
- display: 'flex',
- justifyContent: 'center',
- position: 'absolute',
- bottom: 120,
- left: '50%',
- transform: 'translateX(-50%)',
- width,
- height,
- ...style,
- }}
- >
- <BasicCaptionsContent
- captions={captions}
- combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}
- playbackRate={playbackRate}
- trimBefore={trimBefore ?? 0}
- />
- </div>
- </Sequence>
- );
- },
-);
+ <BasicCaptionsContent
+ captions={captions}
+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}
+ playbackRate={playbackRate}
+ trimBefore={trimBefore ?? 0}
+ />
+ </div>
+ </Sequence>
+ );
+};
export const BasicCaptions = Interactive.withSchema({
Component: BasicCaptionsInner,
diff --git a/packages/docs/docs/interactive-with-schema.mdx b/packages/docs/docs/interactive-with-schema.mdx
index 03b52ca1a0..74b0066b26 100644
--- a/packages/docs/docs/interactive-with-schema.mdx
+++ b/packages/docs/docs/interactive-with-schema.mdx
@@ -14,7 +14,7 @@ Use it when you build a component that should behave like [`<Sequence>`](/docs/s
## Example
```tsx twoslash title="Circle.tsx"
-import {forwardRef, useImperativeHandle, useRef} from 'react';
+import type React from 'react';
import {
Interactive,
Sequence,
@@ -48,48 +48,37 @@ const circleSchema = {
...Interactive.transformSchema,
} as const satisfies InteractivitySchema;
-const CircleInner = forwardRef<
- HTMLDivElement,
- CircleProps & {
- readonly controls: SequenceControls | undefined;
- }
->(
- (
- {
- radius = 80,
- color = '#0b84ff',
- name,
- style,
- controls,
- ...sequenceProps
- },
- ref,
- ) => {
- const elementRef = useRef<HTMLDivElement>(null);
-
- useImperativeHandle(ref, () => elementRef.current as HTMLDivElement, []);
-
- return (
- <Sequence
- layout="none"
- {...sequenceProps}
- name={name ?? '<Circle>'}
- controls={controls}
- >
- <div
- ref={elementRef}
- style={{
- ...style,
- width: radius * 2,
- height: radius * 2,
- borderRadius: '50%',
- backgroundColor: color,
- }}
- />
- </Sequence>
- );
- },
-);
+const CircleInner: React.FC<
+ CircleProps & {
+ readonly controls: SequenceControls | undefined;
+ }
+> = ({
+ radius = 80,
+ color = '#0b84ff',
+ name,
+ style,
+ controls,
+ ...sequenceProps
+}) => {
+ return (
+ <Sequence
+ layout="none"
+ {...sequenceProps}
+ name={name ?? '<Circle>'}
+ controls={controls}
+ >
+ <div
+ style={{
+ ...style,
+ width: radius * 2,
+ height: radius * 2,
+ borderRadius: '50%',
+ backgroundColor: color,
+ }}
+ />
+ </Sequence>
+ );
+};
export const Circle = Interactive.withSchema({
Component: CircleInner,
diff --git a/packages/docs/docs/studio/make-component-interactive.mdx b/packages/docs/docs/studio/make-component-interactive.mdx
index 63a9b090cc..dca75dd563 100644
--- a/packages/docs/docs/studio/make-component-interactive.mdx
+++ b/packages/docs/docs/studio/make-component-interactive.mdx
@@ -80,7 +80,7 @@ The inner component receives a `controls` prop from `Interactive.withSchema()`.
Forward it unchanged to the [`<Sequence>`](/docs/sequence) that represents your component in the timeline. Forwarding it also allows the Studio to associate the timeline item with the outer component's source location.
```tsx twoslash title="Badge.tsx"
-import React, {forwardRef, useImperativeHandle, useRef} from 'react';
+import type React from 'react';
import {
Interactive,
Sequence,
@@ -115,53 +115,42 @@ const badgeSchema = {
...Interactive.transformSchema,
} as const satisfies InteractivitySchema;
// ---cut---
-const BadgeInner = forwardRef<
- HTMLDivElement,
- BadgeProps & {
- readonly controls: SequenceControls | undefined;
- }
->(
- (
- {
- children,
- color = '#0b84ff',
- padding = 16,
- style,
- name,
- controls,
- ...sequenceProps
- },
- ref,
- ) => {
- const elementRef = useRef<HTMLDivElement>(null);
-
- useImperativeHandle(ref, () => elementRef.current as HTMLDivElement, []);
-
- return (
- <Sequence
- layout="none"
- {...sequenceProps}
- name={name ?? '<Badge>'}
- controls={controls}
- >
- <div
- ref={elementRef}
- style={{
- ...style,
- display: 'inline-flex',
- borderRadius: 999,
- backgroundColor: color,
- color: 'white',
- fontWeight: 700,
- padding,
- }}
- >
- {children}
- </div>
- </Sequence>
- );
- },
-);
+const BadgeInner: React.FC<
+ BadgeProps & {
+ readonly controls: SequenceControls | undefined;
+ }
+> = ({
+ children,
+ color = '#0b84ff',
+ padding = 16,
+ style,
+ name,
+ controls,
+ ...sequenceProps
+}) => {
+ return (
+ <Sequence
+ layout="none"
+ {...sequenceProps}
+ name={name ?? '<Badge>'}
+ controls={controls}
+ >
+ <div
+ style={{
+ ...style,
+ display: 'inline-flex',
+ borderRadius: 999,
+ backgroundColor: color,
+ color: 'white',
+ fontWeight: 700,
+ padding,
+ }}
+ >
+ {children}
+ </div>
+ </Sequence>
+ );
+};
```
The exported component should not expose `controls` as a public prop.
@@ -171,7 +160,7 @@ With `<Sequence layout="none">`, the Studio discovers the rendered element autom
## Wrap the component
```tsx twoslash title="Badge.tsx"
-import React, {forwardRef, useImperativeHandle, useRef} from 'react';
+import type React from 'react';
import {
Interactive,
Sequence,
@@ -206,53 +195,42 @@ const badgeSchema = {
...Interactive.transformSchema,
} as const satisfies InteractivitySchema;
-const BadgeInner = forwardRef<
- HTMLDivElement,
- BadgeProps & {
- readonly controls: SequenceControls | undefined;
- }
->(
- (
- {
- children,
- color = '#0b84ff',
- padding = 16,
- style,
- name,
- controls,
- ...sequenceProps
- },
- ref,
- ) => {
- const elementRef = useRef<HTMLDivElement>(null);
-
- useImperativeHandle(ref, () => elementRef.current as HTMLDivElement, []);
-
- return (
- <Sequence
- layout="none"
- {...sequenceProps}
- name={name ?? '<Badge>'}
- controls={controls}
- >
- <div
- ref={elementRef}
- style={{
- ...style,
- display: 'inline-flex',
- borderRadius: 999,
- backgroundColor: color,
- color: 'white',
- fontWeight: 700,
- padding,
- }}
- >
- {children}
- </div>
- </Sequence>
- );
- },
-);
+const BadgeInner: React.FC<
+ BadgeProps & {
+ readonly controls: SequenceControls | undefined;
+ }
+> = ({
+ children,
+ color = '#0b84ff',
+ padding = 16,
+ style,
+ name,
+ controls,
+ ...sequenceProps
+}) => {
+ return (
+ <Sequence
+ layout="none"
+ {...sequenceProps}
+ name={name ?? '<Badge>'}
+ controls={controls}
+ >
+ <div
+ style={{
+ ...style,
+ display: 'inline-flex',
+ borderRadius: 999,
+ backgroundColor: color,
+ color: 'white',
+ fontWeight: 700,
+ padding,
+ }}
+ >
+ {children}
+ </div>
+ </Sequence>
+ );
+};
// ---cut---
export const Badge = Interactive.withSchema({
Component: BadgeInner,
diff --git a/packages/docs/elements/audio/mirrored-spectrum/mirrored-spectrum.tsx b/packages/docs/elements/audio/mirrored-spectrum/mirrored-spectrum.tsx
index c1ae2a7e8a..94836b0954 100644
--- a/packages/docs/elements/audio/mirrored-spectrum/mirrored-spectrum.tsx
+++ b/packages/docs/elements/audio/mirrored-spectrum/mirrored-spectrum.tsx
@@ -1,6 +1,6 @@
import {Audio} from '@remotion/media';
import {useWindowedAudioData, visualizeAudio} from '@remotion/media-utils';
-import React, {forwardRef, useImperativeHandle, useRef} from 'react';
+import React from 'react';
import {
Interactive,
Sequence,
@@ -60,10 +60,9 @@ const MirroredAudioSpectrumContent: React.FC<{
readonly audioSrc: string;
readonly barColor: string;
readonly numberOfBars: number;
- readonly elementRef: React.RefObject<HTMLDivElement | null>;
readonly sensitivity: number;
readonly style: MirroredAudioSpectrumProps['style'];
-}> = ({audioSrc, barColor, numberOfBars, elementRef, sensitivity, style}) => {
+}> = ({audioSrc, barColor, numberOfBars, sensitivity, style}) => {
const frame = useCurrentFrame();
const {fps} = useVideoConfig();
const {audioData, dataOffsetInSeconds} = useWindowedAudioData({
@@ -95,7 +94,6 @@ const MirroredAudioSpectrumContent: React.FC<{
return (
<div
- ref={elementRef}
style={{
alignItems: 'center',
boxSizing: 'border-box',
@@ -127,45 +125,35 @@ const MirroredAudioSpectrumContent: React.FC<{
);
};
-const MirroredAudioSpectrumInner = forwardRef<
- HTMLDivElement,
+const MirroredAudioSpectrumInner: React.FC<
MirroredAudioSpectrumProps & {readonly controls: SequenceControls | undefined}
->(
- (
- {
- audioSrc = 'https://remotion.media/elements/remotion-made-this-picture-move.mp3',
- barColor = '#2563eb',
- controls,
- name,
- numberOfBars = 65,
- sensitivity = 1.5,
- style,
- ...sequenceProps
- },
- ref,
- ) => {
- const elementRef = useRef<HTMLDivElement>(null);
- useImperativeHandle(ref, () => elementRef.current as HTMLDivElement, []);
-
- return (
- <Sequence
- layout="none"
- {...sequenceProps}
- controls={controls}
- name={name ?? 'Mirrored audio spectrum'}
- >
- <MirroredAudioSpectrumContent
- audioSrc={audioSrc}
- barColor={barColor}
- numberOfBars={numberOfBars}
- elementRef={elementRef}
- sensitivity={sensitivity}
- style={style}
- />
- </Sequence>
- );
- },
-);
+> = ({
+ audioSrc = 'https://remotion.media/elements/remotion-made-this-picture-move.mp3',
+ barColor = '#2563eb',
+ controls,
+ name,
+ numberOfBars = 65,
+ sensitivity = 1.5,
+ style,
+ ...sequenceProps
+}) => {
+ return (
+ <Sequence
+ layout="none"
+ {...sequenceProps}
+ controls={controls}
+ name={name ?? 'Mirrored audio spectrum'}
+ >
+ <MirroredAudioSpectrumContent
+ audioSrc={audioSrc}
+ barColor={barColor}
+ numberOfBars={numberOfBars}
+ sensitivity={sensitivity}
+ style={style}
+ />
+ </Sequence>
+ );
+};
export const MirroredAudioSpectrum = Interactive.withSchema({
Component: MirroredAudioSpectrumInner,
diff --git a/packages/docs/elements/audio/oscilloscope/audio-oscilloscope.tsx b/packages/docs/elements/audio/oscilloscope/audio-oscilloscope.tsx
index ec15eee4e3..9fdaf67414 100644
--- a/packages/docs/elements/audio/oscilloscope/audio-oscilloscope.tsx
+++ b/packages/docs/elements/audio/oscilloscope/audio-oscilloscope.tsx
@@ -4,7 +4,7 @@ import {
getWaveformPortion,
useWindowedAudioData,
} from '@remotion/media-utils';
-import React, {forwardRef, useImperativeHandle, useRef} from 'react';
+import React from 'react';
import {
Interactive,
Sequence,
@@ -74,18 +74,9 @@ const AudioOscilloscopeContent: React.FC<{
readonly audioSrc: string;
readonly lineColor: string;
readonly lineWidth: number;
- readonly elementRef: React.RefObject<HTMLDivElement | null>;
readonly style: AudioOscilloscopeProps['style'];
readonly windowInSeconds: number;
-}> = ({
- amplitude,
- audioSrc,
- lineColor,
- lineWidth,
- elementRef,
- style,
- windowInSeconds,
-}) => {
+}> = ({amplitude, audioSrc, lineColor, lineWidth, style, windowInSeconds}) => {
const frame = useCurrentFrame();
const {fps} = useVideoConfig();
const {audioData, dataOffsetInSeconds} = useWindowedAudioData({
@@ -116,7 +107,6 @@ const AudioOscilloscopeContent: React.FC<{
return (
<div
- ref={elementRef}
style={{
boxSizing: 'border-box',
height: 300,
@@ -151,48 +141,37 @@ const AudioOscilloscopeContent: React.FC<{
);
};
-const AudioOscilloscopeInner = forwardRef<
- HTMLDivElement,
+const AudioOscilloscopeInner: React.FC<
AudioOscilloscopeProps & {readonly controls: SequenceControls | undefined}
->(
- (
- {
- amplitude = 2,
- audioSrc = 'https://remotion.media/elements/remotion-made-this-picture-move.mp3',
- controls,
- lineColor = '#2563eb',
- lineWidth = 6,
- name,
- style,
- windowInSeconds = 0.35,
- ...sequenceProps
- },
- ref,
- ) => {
- const elementRef = useRef<HTMLDivElement>(null);
-
- useImperativeHandle(ref, () => elementRef.current as HTMLDivElement, []);
-
- return (
- <Sequence
- layout="none"
- {...sequenceProps}
- controls={controls}
- name={name ?? 'Audio oscilloscope'}
- >
- <AudioOscilloscopeContent
- amplitude={amplitude}
- audioSrc={audioSrc}
- lineColor={lineColor}
- lineWidth={lineWidth}
- elementRef={elementRef}
- style={style}
- windowInSeconds={windowInSeconds}
- />
- </Sequence>
- );
- },
-);
+> = ({
+ amplitude = 2,
+ audioSrc = 'https://remotion.media/elements/remotion-made-this-picture-move.mp3',
+ controls,
+ lineColor = '#2563eb',
+ lineWidth = 6,
+ name,
+ style,
+ windowInSeconds = 0.35,
+ ...sequenceProps
+}) => {
+ return (
+ <Sequence
+ layout="none"
+ {...sequenceProps}
+ controls={controls}
+ name={name ?? 'Audio oscilloscope'}
+ >
+ <AudioOscilloscopeContent
+ amplitude={amplitude}
+ audioSrc={audioSrc}
+ lineColor={lineColor}
+ lineWidth={lineWidth}
+ style={style}
+ windowInSeconds={windowInSeconds}
+ />
+ </Sequence>
+ );
+};
export const AudioOscilloscope = Interactive.withSchema({
Component: AudioOscilloscopeInner,
diff --git a/packages/docs/elements/audio/waveform-progress/audio-waveform-progress.tsx b/packages/docs/elements/audio/waveform-progress/audio-waveform-progress.tsx
index 0f0e5c1a60..4ef3e8892a 100644
--- a/packages/docs/elements/audio/waveform-progress/audio-waveform-progress.tsx
+++ b/packages/docs/elements/audio/waveform-progress/audio-waveform-progress.tsx
@@ -1,12 +1,6 @@
import {Audio} from '@remotion/media';
import {getWaveformPortion, useWindowedAudioData} from '@remotion/media-utils';
-import React, {
- forwardRef,
- useId,
- useImperativeHandle,
- useMemo,
- useRef,
-} from 'react';
+import React, {useId, useMemo} from 'react';
import {
Interactive,
Sequence,
@@ -173,64 +167,53 @@ const AudioWaveformProgressContent: React.FC<{
);
};
-const AudioWaveformProgressInner = forwardRef<
- HTMLDivElement,
+const AudioWaveformProgressInner: React.FC<
AudioWaveformProgressProps & {
readonly controls: SequenceControls | undefined;
}
->(
- (
- {
- amplitude = 1,
- audioSrc = 'https://remotion.media/elements/remotion-made-this-picture-move.mp3',
- barGap = 5,
- controls,
- durationInFrames = 271,
- name,
- numberOfBars = 64,
- playedColor = '#2563eb',
- style,
- unplayedColor = '#cbd5e1',
- ...sequenceProps
- },
- ref,
- ) => {
- const elementRef = useRef<HTMLDivElement>(null);
-
- useImperativeHandle(ref, () => elementRef.current as HTMLDivElement, []);
-
- return (
- <Sequence
- layout="none"
- {...sequenceProps}
- controls={controls}
- durationInFrames={durationInFrames}
- name={name ?? 'Audio waveform progress'}
+> = ({
+ amplitude = 1,
+ audioSrc = 'https://remotion.media/elements/remotion-made-this-picture-move.mp3',
+ barGap = 5,
+ controls,
+ durationInFrames = 271,
+ name,
+ numberOfBars = 64,
+ playedColor = '#2563eb',
+ style,
+ unplayedColor = '#cbd5e1',
+ ...sequenceProps
+}) => {
+ return (
+ <Sequence
+ layout="none"
+ {...sequenceProps}
+ controls={controls}
+ durationInFrames={durationInFrames}
+ name={name ?? 'Audio waveform progress'}
+ >
+ <div
+ style={{
+ boxSizing: 'border-box',
+ height: 300,
+ width: 900,
+ ...style,
+ }}
>
- <div
- ref={elementRef}
- style={{
- boxSizing: 'border-box',
- height: 300,
- width: 900,
- ...style,
- }}
- >
- <AudioWaveformProgressContent
- key={`${audioSrc}-${durationInFrames}`}
- amplitude={amplitude}
- audioSrc={audioSrc}
- barGap={barGap}
- durationInFrames={durationInFrames}
- numberOfBars={numberOfBars}
- playedColor={playedColor}
- unplayedColor={unplayedColor}
- />
- </div>
- </Sequence>
- );
- },
-);
+ <AudioWaveformProgressContent
+ key={`${audioSrc}-${durationInFrames}`}
+ amplitude={amplitude}
+ audioSrc={audioSrc}
+ barGap={barGap}
+ durationInFrames={durationInFrames}
+ numberOfBars={numberOfBars}
+ playedColor={playedColor}
+ unplayedColor={unplayedColor}
+ />
+ </div>
+ </Sequence>
+ );
+};
export const AudioWaveformProgress = Interactive.withSchema({
Component: AudioWaveformProgressInner,
diff --git a/packages/docs/elements/captions/basic-captions/basic-captions.tsx b/packages/docs/elements/captions/basic-captions/basic-captions.tsx
index 101309bc07..faf37d42c3 100644
--- a/packages/docs/elements/captions/basic-captions/basic-captions.tsx
+++ b/packages/docs/elements/captions/basic-captions/basic-captions.tsx
@@ -1,6 +1,6 @@
import type {Caption} from '@remotion/captions';
import {createTikTokStyleCaptions} from '@remotion/captions';
-import React, {forwardRef, useImperativeHandle, useMemo, useRef} from 'react';
+import React, {useMemo} from 'react';
import {
Interactive,
Sequence,
@@ -113,62 +113,51 @@ const BasicCaptionsContent: React.FC<{
);
};
-const BasicCaptionsInner = forwardRef<
- HTMLDivElement,
+const BasicCaptionsInner: React.FC<
BasicCaptionsProps & {
readonly controls: SequenceControls | undefined;
}
->(
- (
- {
- captions,
- combineTokensWithinMilliseconds = defaultCombineTokensWithinMilliseconds,
- controls,
- height = defaultHeight,
- name,
- playbackRate = 1,
- style,
- trimBefore,
- width = defaultWidth,
- ...interactiveProps
- },
- ref,
- ) => {
- const elementRef = useRef<HTMLDivElement>(null);
-
- useImperativeHandle(ref, () => elementRef.current as HTMLDivElement, []);
-
- return (
- <Sequence
- layout="none"
- {...interactiveProps}
- controls={controls}
- name={name ?? '<BasicCaptions>'}
- trimBefore={trimBefore}
+> = ({
+ captions,
+ combineTokensWithinMilliseconds = defaultCombineTokensWithinMilliseconds,
+ controls,
+ height = defaultHeight,
+ name,
+ playbackRate = 1,
+ style,
+ trimBefore,
+ width = defaultWidth,
+ ...interactiveProps
+}) => {
+ return (
+ <Sequence
+ layout="none"
+ {...interactiveProps}
+ controls={controls}
+ name={name ?? '<BasicCaptions>'}
+ trimBefore={trimBefore}
+ >
+ <div
+ style={{
+ alignItems: 'center',
+ display: 'flex',
+ justifyContent: 'center',
+ marginInline: 'auto',
+ width,
+ height,
+ ...style,
+ }}
>
- <div
- ref={elementRef}
- style={{
- alignItems: 'center',
- display: 'flex',
- justifyContent: 'center',
- marginInline: 'auto',
- width,
- height,
- ...style,
- }}
- >
- <BasicCaptionsContent
- captions={captions}
- combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}
- playbackRate={playbackRate}
- trimBefore={trimBefore ?? 0}
- />
- </div>
- </Sequence>
- );
- },
-);
+ <BasicCaptionsContent
+ captions={captions}
+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}
+ playbackRate={playbackRate}
+ trimBefore={trimBefore ?? 0}
+ />
+ </div>
+ </Sequence>
+ );
+};
const BasicCaptionsLayer = Interactive.withSchema({
Component: BasicCaptionsInner,
diff --git a/packages/docs/elements/captions/moving-pill-captions/moving-pill-captions.tsx b/packages/docs/elements/captions/moving-pill-captions/moving-pill-captions.tsx
index 78239f9ffc..4f1ea0b326 100644
--- a/packages/docs/elements/captions/moving-pill-captions/moving-pill-captions.tsx
+++ b/packages/docs/elements/captions/moving-pill-captions/moving-pill-captions.tsx
@@ -3,9 +3,7 @@ import {createTikTokStyleCaptions} from '@remotion/captions';
import {loadFont} from '@remotion/google-fonts/Montserrat';
import {fitText} from '@remotion/layout-utils';
import React, {
- forwardRef,
useEffect,
- useImperativeHandle,
useLayoutEffect,
useMemo,
useRef,
@@ -373,74 +371,62 @@ const MovingPillCaptionsContent: React.FC<{
);
};
-const MovingPillCaptionsInner = forwardRef<
- HTMLDivElement,
+const MovingPillCaptionsInner: React.FC<
MovingPillCaptionsProps & {
readonly controls: SequenceControls | undefined;
}
->(
- (
- {
- captions,
- combineTokensWithinMilliseconds = defaultCombineTokensWithinMilliseconds,
- controls,
- height = defaultHeight,
- name,
- playbackRate = 1,
- style,
- trimBefore,
- width = defaultWidth,
- ...interactiveProps
- },
- ref,
- ) => {
- const elementRef = useRef<HTMLDivElement>(null);
- const [fontLoaded, setFontLoaded] = useState(false);
+> = ({
+ captions,
+ combineTokensWithinMilliseconds = defaultCombineTokensWithinMilliseconds,
+ controls,
+ height = defaultHeight,
+ name,
+ playbackRate = 1,
+ style,
+ trimBefore,
+ width = defaultWidth,
+ ...interactiveProps
+}) => {
+ const [fontLoaded, setFontLoaded] = useState(false);
- useImperativeHandle(ref, () => elementRef.current as HTMLDivElement, []);
+ useEffect(() => {
+ waitUntilDone()
+ .then(() => {
+ setFontLoaded(true);
+ })
+ .catch((error) => {
+ cancelRender(error instanceof Error ? error : new Error(String(error)));
+ });
+ }, []);
- useEffect(() => {
- waitUntilDone()
- .then(() => {
- setFontLoaded(true);
- })
- .catch((error) => {
- cancelRender(
- error instanceof Error ? error : new Error(String(error)),
- );
- });
- }, []);
-
- return (
- <Sequence
- layout="none"
- {...interactiveProps}
- controls={controls}
- name={name ?? '<MovingPillCaptions>'}
- trimBefore={trimBefore}
+ return (
+ <Sequence
+ layout="none"
+ {...interactiveProps}
+ controls={controls}
+ name={name ?? '<MovingPillCaptions>'}
+ trimBefore={trimBefore}
+ >
+ <div
+ style={{
+ height,
+ marginInline: 'auto',
+ width,
+ ...style,
+ }}
>
- <div
- ref={elementRef}
- style={{
- height,
- marginInline: 'auto',
- width,
- ...style,
- }}
- >
- <MovingPillCaptionsContent
- captionAreaWidth={width ?? null}
- captions={captions}
- combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}
- fontLoaded={fontLoaded}
- playbackRate={playbackRate}
- trimBefore={trimBefore ?? 0}
- />
- </div>
- </Sequence>
- );
- },
-);
+ <MovingPillCaptionsContent
+ captionAreaWidth={width ?? null}
+ captions={captions}
+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}
+ fontLoaded={fontLoaded}
+ playbackRate={playbackRate}
+ trimBefore={trimBefore ?? 0}
+ />
+ </div>
+ </Sequence>
+ );
+};
const MovingPillCaptionsLayer = Interactive.withSchema({
Component: MovingPillCaptionsInner,
diff --git a/packages/docs/elements/captions/popping-word-captions/popping-word-captions.tsx b/packages/docs/elements/captions/popping-word-captions/popping-word-captions.tsx
index 366a2ff954..c3804d5388 100644
--- a/packages/docs/elements/captions/popping-word-captions/popping-word-captions.tsx
+++ b/packages/docs/elements/captions/popping-word-captions/popping-word-captions.tsx
@@ -2,14 +2,7 @@ import type {Caption, TikTokPage, TikTokToken} from '@remotion/captions';
import {createTikTokStyleCaptions} from '@remotion/captions';
import {loadFont} from '@remotion/google-fonts/Montserrat';
import {fitText} from '@remotion/layout-utils';
-import React, {
- forwardRef,
- useEffect,
- useImperativeHandle,
- useMemo,
- useRef,
- useState,
-} from 'react';
+import React, {useEffect, useMemo, useState} from 'react';
import {
cancelRender,
Interactive,
@@ -284,74 +277,62 @@ const PoppingWordCaptionsContent: React.FC<{
);
};
-const PoppingWordCaptionsInner = forwardRef<
- HTMLDivElement,
+const PoppingWordCaptionsInner: React.FC<
PoppingWordCaptionsProps & {
readonly controls: SequenceControls | undefined;
}
->(
- (
- {
- captions,
- combineTokensWithinMilliseconds = defaultCombineTokensWithinMilliseconds,
- controls,
- height = defaultHeight,
- name,
- playbackRate = 1,
- style,
- trimBefore,
- width = defaultWidth,
- ...interactiveProps
- },
- ref,
- ) => {
- const elementRef = useRef<HTMLDivElement>(null);
- const [fontLoaded, setFontLoaded] = useState(false);
-
- useImperativeHandle(ref, () => elementRef.current as HTMLDivElement, []);
+> = ({
+ captions,
+ combineTokensWithinMilliseconds = defaultCombineTokensWithinMilliseconds,
+ controls,
+ height = defaultHeight,
+ name,
+ playbackRate = 1,
+ style,
+ trimBefore,
+ width = defaultWidth,
+ ...interactiveProps
+}) => {
+ const [fontLoaded, setFontLoaded] = useState(false);
- useEffect(() => {
- waitUntilDone()
- .then(() => {
- setFontLoaded(true);
- })
- .catch((error) => {
- cancelRender(
- error instanceof Error ? error : new Error(String(error)),
- );
- });
- }, []);
+ useEffect(() => {
+ waitUntilDone()
+ .then(() => {
+ setFontLoaded(true);
+ })
+ .catch((error) => {
+ cancelRender(error instanceof Error ? error : new Error(String(error)));
+ });
+ }, []);
- return (
- <Sequence
- layout="none"
- {...interactiveProps}
- controls={controls}
- name={name ?? '<PoppingWordCaptions>'}
- trimBefore={trimBefore}
+ return (
+ <Sequence
+ layout="none"
+ {...interactiveProps}
+ controls={controls}
+ name={name ?? '<PoppingWordCaptions>'}
+ trimBefore={trimBefore}
+ >
+ <div
+ style={{
+ height,
+ marginInline: 'auto',
+ width,
+ ...style,
+ }}
>
- <div
- ref={elementRef}
- style={{
- height,
- marginInline: 'auto',
- width,
- ...style,
- }}
- >
- <PoppingWordCaptionsContent
- captionAreaWidth={width ?? null}
- captions={captions}
- combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}
- fontLoaded={fontLoaded}
- playbackRate={playbackRate}
- trimBefore={trimBefore ?? 0}
- />
- </div>
- </Sequence>
- );
- },
-);
+ <PoppingWordCaptionsContent
+ captionAreaWidth={width ?? null}
+ captions={captions}
+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}
+ fontLoaded={fontLoaded}
+ playbackRate={playbackRate}
+ trimBefore={trimBefore ?? 0}
+ />
+ </div>
+ </Sequence>
+ );
+};
const PoppingWordCaptionsLayer = Interactive.withSchema({
Component: PoppingWordCaptionsInner,
diff --git a/packages/docs/elements/captions/rounded-captions/rounded-captions.tsx b/packages/docs/elements/captions/rounded-captions/rounded-captions.tsx
index 937d7a6343..2fc42e960e 100644
--- a/packages/docs/elements/captions/rounded-captions/rounded-captions.tsx
+++ b/packages/docs/elements/captions/rounded-captions/rounded-captions.tsx
@@ -3,14 +3,7 @@ import {createTikTokStyleCaptions} from '@remotion/captions';
import {loadFont} from '@remotion/google-fonts/Figtree';
import {fitTextOnNLines, measureText} from '@remotion/layout-utils';
import {createRoundedTextBox} from '@remotion/rounded-text-box';
-import React, {
- forwardRef,
- useEffect,
- useImperativeHandle,
- useMemo,
- useRef,
- useState,
-} from 'react';
+import React, {useEffect, useMemo, useState} from 'react';
import {
cancelRender,
Interactive,
@@ -212,75 +205,65 @@ const RoundedCaptionsContent: React.FC<{
);
};
-const RoundedCaptionsInner = forwardRef<
- HTMLDivElement,
+const RoundedCaptionsInner: React.FC<
RoundedCaptionsProps & {
readonly controls: SequenceControls | undefined;
}
->(
- (
- {
- captions,
- combineTokensWithinMilliseconds,
- controls,
- height = defaultHeight,
- name,
- playbackRate,
- style,
- trimBefore,
- width = defaultWidth,
- ...interactiveProps
- },
- ref,
- ) => {
- const elementRef = useRef<HTMLDivElement>(null);
- const [fontLoaded, setFontLoaded] = useState(false);
-
- useImperativeHandle(ref, () => elementRef.current as HTMLDivElement, []);
+> = ({
+ captions,
+ combineTokensWithinMilliseconds,
+ controls,
+ height = defaultHeight,
+ name,
+ playbackRate,
+ style,
+ trimBefore,
+ width = defaultWidth,
+ ...interactiveProps
+}) => {
+ const [fontLoaded, setFontLoaded] = useState(false);
- useEffect(() => {
- waitUntilDone()
- .then(() => setFontLoaded(true))
- .catch((error) => cancelRender(error));
- }, []);
+ useEffect(() => {
+ waitUntilDone()
+ .then(() => setFontLoaded(true))
+ .catch((error) => cancelRender(error));
+ }, []);
- return (
- <Sequence
- layout="none"
- {...interactiveProps}
- controls={controls}
- name={name ?? '<RoundedCaptions>'}
- trimBefore={trimBefore}
+ return (
+ <Sequence
+ layout="none"
+ {...interactiveProps}
+ controls={controls}
+ name={name ?? '<RoundedCaptions>'}
+ trimBefore={trimBefore}
+ >
+ <div
+ style={{
+ alignItems: 'center',
+ display: 'flex',
+ justifyContent: 'center',
+ marginInline: 'auto',
+ width,
+ height,
+ ...style,
+ }}
>
- <div
- ref={elementRef}
- style={{
- alignItems: 'center',
- display: 'flex',
- justifyContent: 'center',
- marginInline: 'auto',
- width,
- height,
- ...style,
- }}
- >
- <RoundedCaptionsContent
- captions={captions}
- combineTokensWithinMilliseconds={
- combineTokensWithinMilliseconds ??
- defaultCombineTokensWithinMilliseconds
- }
- fontLoaded={fontLoaded}
- playbackRate={playbackRate ?? 1}
- trimBefore={trimBefore ?? 0}
- width={width}
- height={height}
- />
- </div>
- </Sequence>
- );
- },
-);
+ <RoundedCaptionsContent
+ captions={captions}
+ combineTokensWithinMilliseconds={
+ combineTokensWithinMilliseconds ??
+ defaultCombineTokensWithinMilliseconds
+ }
+ fontLoaded={fontLoaded}
+ playbackRate={playbackRate ?? 1}
+ trimBefore={trimBefore ?? 0}
+ width={width}
+ height={height}
+ />
+ </div>
+ </Sequence>
+ );
+};
export const RoundedCaptions = Interactive.withSchema({
Component: RoundedCaptionsInner,
diff --git a/packages/docs/elements/captions/word-highlight-captions/word-highlight-captions.tsx b/packages/docs/elements/captions/word-highlight-captions/word-highlight-captions.tsx
index 880f2512da..df455809ca 100644
--- a/packages/docs/elements/captions/word-highlight-captions/word-highlight-captions.tsx
+++ b/packages/docs/elements/captions/word-highlight-captions/word-highlight-captions.tsx
@@ -2,14 +2,7 @@ import type {Caption, TikTokPage, TikTokToken} from '@remotion/captions';
import {createTikTokStyleCaptions} from '@remotion/captions';
import {loadFont} from '@remotion/google-fonts/Montserrat';
import {fitText} from '@remotion/layout-utils';
-import React, {
- forwardRef,
- useEffect,
- useImperativeHandle,
- useMemo,
- useRef,
- useState,
-} from 'react';
+import React, {useEffect, useMemo, useState} from 'react';
import {
cancelRender,
Interactive,
@@ -242,74 +235,62 @@ const WordHighlightCaptionsContent: React.FC<{
);
};
-const WordHighlightCaptionsInner = forwardRef<
- HTMLDivElement,
+const WordHighlightCaptionsInner: React.FC<
WordHighlightCaptionsProps & {
readonly controls: SequenceControls | undefined;
}
->(
- (
- {
- captions,
- combineTokensWithinMilliseconds = defaultCombineTokensWithinMilliseconds,
- controls,
- height = defaultHeight,
- name,
- playbackRate = 1,
- style,
- trimBefore,
- width = defaultWidth,
- ...interactiveProps
- },
- ref,
- ) => {
- const elementRef = useRef<HTMLDivElement>(null);
- const [fontLoaded, setFontLoaded] = useState(false);
-
- useImperativeHandle(ref, () => elementRef.current as HTMLDivElement, []);
+> = ({
+ captions,
+ combineTokensWithinMilliseconds = defaultCombineTokensWithinMilliseconds,
+ controls,
+ height = defaultHeight,
+ name,
+ playbackRate = 1,
+ style,
+ trimBefore,
+ width = defaultWidth,
+ ...interactiveProps
+}) => {
+ const [fontLoaded, setFontLoaded] = useState(false);
- useEffect(() => {
- waitUntilDone()
- .then(() => {
- setFontLoaded(true);
- })
- .catch((error) => {
- cancelRender(
- error instanceof Error ? error : new Error(String(error)),
- );
- });
- }, []);
+ useEffect(() => {
+ waitUntilDone()
+ .then(() => {
+ setFontLoaded(true);
+ })
+ .catch((error) => {
+ cancelRender(error instanceof Error ? error : new Error(String(error)));
+ });
+ }, []);
- return (
- <Sequence
- layout="none"
- {...interactiveProps}
- controls={controls}
- name={name ?? '<WordHighlightCaptions>'}
- trimBefore={trimBefore}
+ return (
+ <Sequence
+ layout="none"
+ {...interactiveProps}
+ controls={controls}
+ name={name ?? '<WordHighlightCaptions>'}
+ trimBefore={trimBefore}
+ >
+ <div
+ style={{
+ height,
+ marginInline: 'auto',
+ width,
+ ...style,
+ }}
>
- <div
- ref={elementRef}
- style={{
- height,
- marginInline: 'auto',
- width,
- ...style,
- }}
- >
- <WordHighlightCaptionsContent
- captionAreaWidth={width ?? null}
- captions={captions}
- combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}
- fontLoaded={fontLoaded}
- playbackRate={playbackRate}
- trimBefore={trimBefore ?? 0}
- />
- </div>
- </Sequence>
- );
- },
-);
+ <WordHighlightCaptionsContent
+ captionAreaWidth={width ?? null}
+ captions={captions}
+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}
+ fontLoaded={fontLoaded}
+ playbackRate={playbackRate}
+ trimBefore={trimBefore ?? 0}
+ />
+ </div>
+ </Sequence>
+ );
+};
const WordHighlightCaptionsLayer = Interactive.withSchema({
Component: WordHighlightCaptionsInner,
diff --git a/packages/docs/elements/commerce/product-collection/product-collection.tsx b/packages/docs/elements/commerce/product-collection/product-collection.tsx
index f9e9c2e316..43130f9e91 100644
--- a/packages/docs/elements/commerce/product-collection/product-collection.tsx
+++ b/packages/docs/elements/commerce/product-collection/product-collection.tsx
@@ -1,5 +1,5 @@
import {loadFont} from '@remotion/google-fonts/Inter';
-import React, {forwardRef, useImperativeHandle, useRef} from 'react';
+import React from 'react';
import {
Easing,
Img,
@@ -40,11 +40,9 @@ const productCardSchema = {
...Interactive.transformSchema,
} as const satisfies InteractivitySchema;
-const ProductCardInner = forwardRef<
- HTMLDivElement,
+const ProductCardInner: React.FC<
ProductCardProps & {readonly controls: SequenceControls | undefined}
->(({controls, count, index, label, name, style, ...sequenceProps}, ref) => {
- const elementRef = useRef<HTMLDivElement>(null);
+> = ({controls, count, index, label, name, style, ...sequenceProps}) => {
const frame = useCurrentFrame();
const lastProductIndex = Math.max(0, count - 1);
const rawScrollPosition = interpolate(
@@ -101,8 +99,6 @@ const ProductCardInner = forwardRef<
extrapolateRight: 'clamp',
});
- useImperativeHandle(ref, () => elementRef.current as HTMLDivElement, []);
-
return (
<Sequence
layout="none"
@@ -127,7 +123,6 @@ const ProductCardInner = forwardRef<
}}
>
<div
- ref={elementRef}
style={{
...style,
backgroundColor: '#ffffff',
@@ -182,7 +177,7 @@ const ProductCardInner = forwardRef<
</div>
</Sequence>
);
-});
+};
const ProductCard = Interactive.withSchema({
Component: ProductCardInner,
diff --git a/packages/docs/elements/guidelines.mdx b/packages/docs/elements/guidelines.mdx
index 8bf1a6632f..fb824fa676 100644
--- a/packages/docs/elements/guidelines.mdx
+++ b/packages/docs/elements/guidelines.mdx
@@ -54,7 +54,7 @@ Export the schema-enabled component directly and wire up the common props:
- Add [`Interactive.baseSchema`](/docs/interactive#interactivebaseschema) to every `Interactive.withSchema()` schema and pass `controls` unchanged to the component's `<Sequence>`.
- Pass `from`, `durationInFrames`, `trimBefore`, `playbackRate`, `loop`, `freeze`, `hidden`, `name`, and `showInTimeline` to that Sequence.
-- Pass `style` and the ref to the rendered element. With `layout="none"`, Studio discovers the outline automatically. Set the dimensions in the component because Element metadata does not pass them as props.
+- Pass `style` to the rendered element. With `layout="none"`, Studio discovers the outline automatically. Set the dimensions in the component because Element metadata does not pass them as props.
- Render frame-dependent animation in a child below the Sequence. This makes [`useCurrentFrame()`](/docs/use-current-frame) respect `from`, `trimBefore`, `durationInFrames`, `playbackRate`, `loop`, and `freeze`. If the component that returns the Sequence calls it, it reads the parent clock.
Export the schema-enabled component directly, without a forwarding wrapper. See the [oscilloscope](/elements/audio/oscilloscope), [waveform progress](/elements/audio/waveform-progress), and [mirrored spectrum](/elements/audio/mirrored-spectrum) Elements.
diff --git a/packages/docs/elements/maps/map-flyover/a-to-b-map-flyover.tsx b/packages/docs/elements/maps/map-flyover/a-to-b-map-flyover.tsx
index bb39c7e9f4..7fd8a0cbfb 100644
--- a/packages/docs/elements/maps/map-flyover/a-to-b-map-flyover.tsx
+++ b/packages/docs/elements/maps/map-flyover/a-to-b-map-flyover.tsx
@@ -3,9 +3,7 @@ import * as maplibregl from 'maplibre-gl';
import {type Map} from 'maplibre-gl';
import 'maplibre-gl/dist/maplibre-gl.css';
import React, {
- forwardRef,
useEffect,
- useImperativeHandle,
useLayoutEffect,
useMemo,
useRef,
@@ -284,7 +282,6 @@ const MapFlyoverContent: React.FC<{
readonly lineWidth: number;
readonly origin: readonly [number, number];
readonly originLabel: string;
- readonly elementRef: React.RefObject<HTMLDivElement | null>;
readonly routeColor: string;
readonly style: React.CSSProperties | null;
}> = ({
@@ -293,7 +290,6 @@ const MapFlyoverContent: React.FC<{
lineWidth,
origin,
originLabel,
- elementRef,
routeColor,
style,
}) => {
@@ -481,7 +477,6 @@ const MapFlyoverContent: React.FC<{
return (
<div
- ref={elementRef}
style={{
backgroundColor: '#dbe4e8',
height,
@@ -608,49 +603,39 @@ const MapFlyoverContent: React.FC<{
);
};
-const MapFlyoverLayerInner = forwardRef<
- HTMLDivElement,
+const MapFlyoverLayerInner: React.FC<
MapFlyoverLayerProps & {readonly controls: SequenceControls | undefined}
->(
- (
- {
- controls,
- destination = [139.6917, 35.6895],
- destinationLabel = 'Tokyo',
- lineWidth = 24,
- name,
- origin = [-0.1276, 51.5072],
- originLabel = 'London',
- routeColor = '#ff5c4d',
- style,
- ...sequenceProps
- },
- ref,
- ) => {
- const elementRef = useRef<HTMLDivElement>(null);
- useImperativeHandle(ref, () => elementRef.current as HTMLDivElement, []);
-
- return (
- <Sequence
- layout="none"
- {...sequenceProps}
- controls={controls}
- name={name ?? 'A-to-B Map Flyover'}
- >
- <MapFlyoverContent
- destination={destination}
- destinationLabel={destinationLabel}
- lineWidth={lineWidth}
- origin={origin}
- originLabel={originLabel}
- elementRef={elementRef}
- routeColor={routeColor}
- style={style ?? null}
- />
- </Sequence>
- );
- },
-);
+> = ({
+ controls,
+ destination = [139.6917, 35.6895],
+ destinationLabel = 'Tokyo',
+ lineWidth = 24,
+ name,
+ origin = [-0.1276, 51.5072],
+ originLabel = 'London',
+ routeColor = '#ff5c4d',
+ style,
+ ...sequenceProps
+}) => {
+ return (
+ <Sequence
+ layout="none"
+ {...sequenceProps}
+ controls={controls}
+ name={name ?? 'A-to-B Map Flyover'}
+ >
+ <MapFlyoverContent
+ destination={destination}
+ destinationLabel={destinationLabel}
+ lineWidth={lineWidth}
+ origin={origin}
+ originLabel={originLabel}
+ routeColor={routeColor}
+ style={style ?? null}
+ />
+ </Sequence>
+ );
+};
export const MapFlyover = Interactive.withSchema({
Component: MapFlyoverLayerInner,
diff --git a/packages/docs/elements/maps/watercolor-map/watercolor-map.tsx b/packages/docs/elements/maps/watercolor-map/watercolor-map.tsx
index 9d25361c5e..dfe48f1595 100644
--- a/packages/docs/elements/maps/watercolor-map/watercolor-map.tsx
+++ b/packages/docs/elements/maps/watercolor-map/watercolor-map.tsx
@@ -1,5 +1,5 @@
import {fontFamily, loadFont} from '@remotion/google-fonts/Lora';
-import React, {forwardRef, useImperativeHandle, useRef} from 'react';
+import React from 'react';
import {
Easing,
Img,
@@ -168,7 +168,6 @@ const WatercolorMapContent: React.FC<{
readonly destinationLabel: string;
readonly origin: Coordinates;
readonly originLabel: string;
- readonly elementRef: React.RefObject<HTMLDivElement | null>;
readonly routeColor: string;
readonly routeWidth: number;
readonly style: React.CSSProperties | undefined;
@@ -177,7 +176,6 @@ const WatercolorMapContent: React.FC<{
destinationLabel,
origin,
originLabel,
- elementRef,
routeColor,
routeWidth,
style,
@@ -256,7 +254,6 @@ const WatercolorMapContent: React.FC<{
return (
<div
- ref={elementRef}
style={{
backgroundColor: '#e6ec88',
height,
@@ -405,49 +402,39 @@ const WatercolorMapContent: React.FC<{
);
};
-const WatercolorMapInner = forwardRef<
- HTMLDivElement,
+const WatercolorMapInner: React.FC<
WatercolorMapProps & {readonly controls: SequenceControls | undefined}
->(
- (
- {
- controls,
- destination = [8.5417, 47.3769],
- destinationLabel = 'Zurich',
- name,
- origin = [-118.2437, 34.0522],
- originLabel = 'Los Angeles',
- routeColor = '#ff0041',
- routeWidth = 18,
- style,
- ...sequenceProps
- },
- ref,
- ) => {
- const elementRef = useRef<HTMLDivElement>(null);
- useImperativeHandle(ref, () => elementRef.current as HTMLDivElement, []);
-
- return (
- <Sequence
- layout="none"
- {...sequenceProps}
- controls={controls}
- name={name ?? 'Watercolor map'}
- >
- <WatercolorMapContent
- destination={destination}
- destinationLabel={destinationLabel}
- origin={origin}
- originLabel={originLabel}
- elementRef={elementRef}
- routeColor={routeColor}
- routeWidth={routeWidth}
- style={style}
- />
- </Sequence>
- );
- },
-);
+> = ({
+ controls,
+ destination = [8.5417, 47.3769],
+ destinationLabel = 'Zurich',
+ name,
+ origin = [-118.2437, 34.0522],
+ originLabel = 'Los Angeles',
+ routeColor = '#ff0041',
+ routeWidth = 18,
+ style,
+ ...sequenceProps
+}) => {
+ return (
+ <Sequence
+ layout="none"
+ {...sequenceProps}
+ controls={controls}
+ name={name ?? 'Watercolor map'}
+ >
+ <WatercolorMapContent
+ destination={destination}
+ destinationLabel={destinationLabel}
+ origin={origin}
+ originLabel={originLabel}
+ routeColor={routeColor}
+ routeWidth={routeWidth}
+ style={style}
+ />
+ </Sequence>
+ );
+};
export const WatercolorMap = Interactive.withSchema({
Component: WatercolorMapInner,
diff --git a/packages/docs/elements/overlays/social-safe-zones/social-safe-zones.tsx b/packages/docs/elements/overlays/social-safe-zones/social-safe-zones.tsx
index 8b78a245c3..c54b7591d9 100644
--- a/packages/docs/elements/overlays/social-safe-zones/social-safe-zones.tsx
+++ b/packages/docs/elements/overlays/social-safe-zones/social-safe-zones.tsx
@@ -1,4 +1,4 @@
-import React, {forwardRef, useImperativeHandle, useRef} from 'react';
+import React from 'react';
import {
CanvasImage,
Interactive,
@@ -29,16 +29,11 @@ const socialSafeZonesSchema = {
...Interactive.transformSchema,
} as const satisfies InteractivitySchema;
-const SocialSafeZonesInner = forwardRef<
- HTMLDivElement,
+const SocialSafeZonesInner: React.FC<
SocialSafeZonesProps & {
readonly controls: SequenceControls | undefined;
}
->(({controls, name, platform = 'instagram', style, ...sequenceProps}, ref) => {
- const elementRef = useRef<HTMLDivElement>(null);
-
- useImperativeHandle(ref, () => elementRef.current as HTMLDivElement, []);
-
+> = ({controls, name, platform = 'instagram', style, ...sequenceProps}) => {
return (
<Sequence
layout="none"
@@ -47,7 +42,6 @@ const SocialSafeZonesInner = forwardRef<
name={name ?? 'Social Safe Zones'}
>
<div
- ref={elementRef}
style={{
...style,
height: 1920,
@@ -96,7 +90,7 @@ const SocialSafeZonesInner = forwardRef<
</div>
</Sequence>
);
-});
+};
export const SocialSafeZones = Interactive.withSchema({
Component: SocialSafeZonesInner,
diff --git a/packages/docs/elements/text/spinning-text-wheel/spinning-text-wheel.tsx b/packages/docs/elements/text/spinning-text-wheel/spinning-text-wheel.tsx
index 42ac02793f..b0bb738d4b 100644
--- a/packages/docs/elements/text/spinning-text-wheel/spinning-text-wheel.tsx
+++ b/packages/docs/elements/text/spinning-text-wheel/spinning-text-wheel.tsx
@@ -1,5 +1,5 @@
import {loadFont} from '@remotion/google-fonts/MonaSans';
-import React, {forwardRef, useImperativeHandle, useRef} from 'react';
+import React from 'react';
import {
Interactive,
Sequence,
@@ -39,137 +39,127 @@ const spinningTextWheelSchema = {
...Interactive.transformSchema,
} as const satisfies InteractivitySchema;
-const SpinningTextWheelInner = forwardRef<
- HTMLDivElement,
+const SpinningTextWheelInner: React.FC<
InteractiveSpinningTextWheelProps & {
readonly controls: SequenceControls | undefined;
}
->(
- (
- {
- callerStyle,
- controls,
- items = 'Friday\nSaturday\nSunday\nMonday\nTuesday\nWednesday\nThursday',
- name,
- style,
- ...sequenceProps
+> = ({
+ callerStyle,
+ controls,
+ items = 'Friday\nSaturday\nSunday\nMonday\nTuesday\nWednesday\nThursday',
+ name,
+ style,
+ ...sequenceProps
+}) => {
+ const frame = useCurrentFrame();
+ const {fps} = useVideoConfig();
+ const values = items
+ .split('\n')
+ .map((item) => item.trim())
+ .filter(Boolean);
+ const progress = spring({
+ fps,
+ frame,
+ config: {
+ mass: 10,
+ damping: 200,
+ stiffness: 200,
},
- ref,
- ) => {
- const frame = useCurrentFrame();
- const {fps} = useVideoConfig();
- const elementRef = useRef<HTMLDivElement>(null);
- const values = items
- .split('\n')
- .map((item) => item.trim())
- .filter(Boolean);
- const progress = spring({
- fps,
- frame,
- config: {
- mass: 10,
- damping: 200,
- stiffness: 200,
- },
- durationInFrames: 90,
- durationRestThreshold: 0.0001,
- });
- const rotation = interpolate(progress, [0, 1], [1, 0]);
- const {
- rotate: callerRotate,
- scale: callerScale,
- transform: callerTransform,
- transformBox: callerTransformBox,
- transformOrigin: callerTransformOrigin,
- transformStyle: callerTransformStyle,
- translate: callerTranslate,
- ...callerContentStyle
- } = callerStyle ?? {};
+ durationInFrames: 90,
+ durationRestThreshold: 0.0001,
+ });
+ const rotation = interpolate(progress, [0, 1], [1, 0]);
+ const {
+ rotate: callerRotate,
+ scale: callerScale,
+ transform: callerTransform,
+ transformBox: callerTransformBox,
+ transformOrigin: callerTransformOrigin,
+ transformStyle: callerTransformStyle,
+ translate: callerTranslate,
+ ...callerContentStyle
+ } = callerStyle ?? {};
- useImperativeHandle(ref, () => elementRef.current as HTMLDivElement, []);
-
- return (
- <Sequence
- layout="none"
- {...sequenceProps}
- controls={controls}
- name={name ?? '<SpinningTextWheel>'}
+ return (
+ <Sequence
+ layout="none"
+ {...sequenceProps}
+ controls={controls}
+ name={name ?? '<SpinningTextWheel>'}
+ >
+ <div
+ style={{
+ rotate: callerRotate,
+ scale: callerScale,
+ transform: callerTransform,
+ transformBox: callerTransformBox,
+ transformOrigin: callerTransformOrigin,
+ transformStyle: callerTransformStyle,
+ translate: callerTranslate,
+ }}
>
<div
style={{
- rotate: callerRotate,
- scale: callerScale,
- transform: callerTransform,
- transformBox: callerTransformBox,
- transformOrigin: callerTransformOrigin,
- transformStyle: callerTransformStyle,
- translate: callerTranslate,
+ height: 200,
+ maskImage:
+ 'linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 1) 30%, rgba(0, 0, 0, 1) 70%, transparent 100%)',
+ overflow: 'hidden',
+ WebkitMaskImage:
+ 'linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 1) 30%, rgba(0, 0, 0, 1) 70%, transparent 100%)',
+ perspective: 10000,
+ position: 'relative',
+ width: 400,
+ ...style,
+ ...callerContentStyle,
}}
>
- <div
- ref={elementRef}
- style={{
- height: 200,
- maskImage:
- 'linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 1) 30%, rgba(0, 0, 0, 1) 70%, transparent 100%)',
- overflow: 'hidden',
- WebkitMaskImage:
- 'linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 1) 30%, rgba(0, 0, 0, 1) 70%, transparent 100%)',
- perspective: 10000,
- position: 'relative',
- width: 400,
- ...style,
- ...callerContentStyle,
- }}
- >
- {values.map((value, index) => {
- const wheelIndex = index / values.length + rotation;
- const angle = wheelIndex * Math.PI * 2;
- const rotateX = wheelIndex * 360;
+ {values.map((value, index) => {
+ const wheelIndex = index / values.length + rotation;
+ const angle = wheelIndex * Math.PI * 2;
+ const rotateX = wheelIndex * 360;
- return (
+ return (
+ <div
+ key={`${index}-${value}`}
+ style={{
+ alignItems: 'center',
+ backfaceVisibility: 'hidden',
+ display: 'flex',
+ height: '100%',
+ justifyContent: 'center',
+ left: 0,
+ opacity:
+ index === 0
+ ? interpolate(progress, [0.88, 1], [0.28, 1], {
+ extrapolateLeft: 'clamp',
+ extrapolateRight: 'clamp',
+ })
+ : 0.28,
+ position: 'absolute',
+ top: 0,
+ perspective: 1000,
+ transform: `translateZ(${Math.cos(angle) * 100}px) translateY(${Math.sin(angle) * 100}px) rotateX(${rotateX}deg)`,
+ width: '100%',
+ }}
+ >
<div
- key={`${index}-${value}`}
style={{
- alignItems: 'center',
backfaceVisibility: 'hidden',
- display: 'flex',
- height: '100%',
- justifyContent: 'center',
- left: 0,
- opacity:
- index === 0
- ? interpolate(progress, [0.88, 1], [0.28, 1], {
- extrapolateLeft: 'clamp',
- extrapolateRight: 'clamp',
- })
- : 0.28,
- position: 'absolute',
- top: 0,
- perspective: 1000,
- transform: `translateZ(${Math.cos(angle) * 100}px) translateY(${Math.sin(angle) * 100}px) rotateX(${rotateX}deg)`,
+ textAlign: 'center',
+ transform: `rotateX(${-rotateX}deg)`,
width: '100%',
}}
>
- <div
- style={{
- backfaceVisibility: 'hidden',
- textAlign: 'center',
- transform: `rotateX(${-rotateX}deg)`,
- width: '100%',
- }}
- >
- {value}
- </div>
+ {value}
</div>
- );
- })}
- </div>
+ </div>
+ );
+ })}
</div>
- </Sequence>
- );
- },
-);
+ </div>
+ </Sequence>
+ );
+};
const InteractiveSpinningTextWheel = Interactive.withSchema({
Component: SpinningTextWheelInner,
diff --git a/packages/example/src/CaptionsTester/AnimatedCaptions.tsx b/packages/example/src/CaptionsTester/AnimatedCaptions.tsx
index 3460dd1506..98f5ffd376 100644
--- a/packages/example/src/CaptionsTester/AnimatedCaptions.tsx
+++ b/packages/example/src/CaptionsTester/AnimatedCaptions.tsx
@@ -1,6 +1,6 @@
import type {Caption, TikTokPage} from '@remotion/captions';
import {createTikTokStyleCaptions} from '@remotion/captions';
-import React, {forwardRef, useImperativeHandle, useMemo, useRef} from 'react';
+import React, {useMemo} from 'react';
import {
AbsoluteFill,
Interactive,
@@ -119,11 +119,9 @@ type AnimatedCaptionsProps = InteractiveBaseProps &
readonly captions: Caption[];
};
-const AnimatedCaptionsInner = forwardRef<
- HTMLDivElement,
+const AnimatedCaptionsInner: React.FC<
AnimatedCaptionsProps & {readonly controls: SequenceControls | undefined}
->(({captions, controls, name, style, ...sequenceProps}, ref) => {
- const elementRef = useRef<HTMLDivElement>(null);
+> = ({captions, controls, name, style, ...sequenceProps}) => {
const {fps} = useVideoConfig();
const pages = useMemo(() => {
return createTikTokStyleCaptions({
@@ -132,11 +130,8 @@ const AnimatedCaptionsInner = forwardRef<
}).pages;
}, [captions]);
- useImperativeHandle(ref, () => elementRef.current as HTMLDivElement, []);
-
return (
<Sequence
- ref={elementRef}
{...sequenceProps}
name={name ?? '<AnimatedCaptions>'}
style={style}
@@ -170,7 +165,7 @@ const AnimatedCaptionsInner = forwardRef<
})}
</Sequence>
);
-});
+};
export const AnimatedCaptions = Interactive.withSchema({
Component: AnimatedCaptionsInner,
diff --git a/packages/example/src/mirrored-spectrum.element.tsx b/packages/example/src/mirrored-spectrum.element.tsx
index c1cd855e5d..4e523d6358 100644
--- a/packages/example/src/mirrored-spectrum.element.tsx
+++ b/packages/example/src/mirrored-spectrum.element.tsx
@@ -1,6 +1,6 @@
import {Audio} from '@remotion/media';
import {useWindowedAudioData, visualizeAudio} from '@remotion/media-utils';
-import React, {forwardRef, useImperativeHandle, useRef} from 'react';
+import React from 'react';
import {
Interactive,
Sequence,
@@ -60,10 +60,9 @@ const MirroredAudioSpectrumContent: React.FC<{
readonly audioSrc: string;
readonly barColor: string;
readonly numberOfBars: number;
- readonly elementRef: React.RefObject<HTMLDivElement | null>;
readonly sensitivity: number;
readonly style: MirroredAudioSpectrumProps['style'];
-}> = ({audioSrc, barColor, numberOfBars, elementRef, sensitivity, style}) => {
+}> = ({audioSrc, barColor, numberOfBars, sensitivity, style}) => {
const frame = useCurrentFrame();
const {fps} = useVideoConfig();
const {audioData, dataOffsetInSeconds} = useWindowedAudioData({
@@ -95,7 +94,6 @@ const MirroredAudioSpectrumContent: React.FC<{
return (
<div
- ref={elementRef}
style={{
alignItems: 'center',
boxSizing: 'border-box',
@@ -127,45 +125,35 @@ const MirroredAudioSpectrumContent: React.FC<{
);
};
-const MirroredAudioSpectrumInner = forwardRef<
- HTMLDivElement,
+const MirroredAudioSpectrumInner: React.FC<
MirroredAudioSpectrumProps & {readonly controls: SequenceControls | undefined}
->(
- (
- {
- audioSrc = 'https://remotion.media/elements/remotion-made-this-picture-move.mp3',
- barColor = '#0b84f3',
- controls,
- name,
- numberOfBars = 65,
- sensitivity = 1.5,
- style,
- ...sequenceProps
- },
- ref,
- ) => {
- const elementRef = useRef<HTMLDivElement>(null);
- useImperativeHandle(ref, () => elementRef.current as HTMLDivElement, []);
-
- return (
- <Sequence
- layout="none"
- {...sequenceProps}
- controls={controls}
- name={name ?? 'Mirrored audio spectrum'}
- >
- <MirroredAudioSpectrumContent
- audioSrc={audioSrc}
- barColor={barColor}
- numberOfBars={numberOfBars}
- elementRef={elementRef}
- sensitivity={sensitivity}
- style={style}
- />
- </Sequence>
- );
- },
-);
+> = ({
+ audioSrc = 'https://remotion.media/elements/remotion-made-this-picture-move.mp3',
+ barColor = '#0b84f3',
+ controls,
+ name,
+ numberOfBars = 65,
+ sensitivity = 1.5,
+ style,
+ ...sequenceProps
+}) => {
+ return (
+ <Sequence
+ layout="none"
+ {...sequenceProps}
+ controls={controls}
+ name={name ?? 'Mirrored audio spectrum'}
+ >
+ <MirroredAudioSpectrumContent
+ audioSrc={audioSrc}
+ barColor={barColor}
+ numberOfBars={numberOfBars}
+ sensitivity={sensitivity}
+ style={style}
+ />
+ </Sequence>
+ );
+};
export const MirroredAudioSpectrum = Interactive.withSchema({
Component: MirroredAudioSpectrumInner,
diff --git a/packages/example/src/moving-pill-captions.element.tsx b/packages/example/src/moving-pill-captions.element.tsx
index 3b67aed574..30503ce70a 100644
--- a/packages/example/src/moving-pill-captions.element.tsx
+++ b/packages/example/src/moving-pill-captions.element.tsx
@@ -3,9 +3,7 @@ import {createTikTokStyleCaptions} from '@remotion/captions';
import {loadFont} from '@remotion/google-fonts/Montserrat';
import {fitText} from '@remotion/layout-utils';
import React, {
- forwardRef,
useEffect,
- useImperativeHandle,
useLayoutEffect,
useMemo,
useRef,
@@ -379,69 +377,57 @@ const MovingPillCaptionsContent: React.FC<{
);
};
-const MovingPillCaptionsInner = forwardRef<
- HTMLDivElement,
+const MovingPillCaptionsInner: React.FC<
MovingPillCaptionsProps & {
readonly controls: SequenceControls | undefined;
}
->(
- (
- {
- captions,
- combineTokensWithinMilliseconds = defaultCombineTokensWithinMilliseconds,
- controls,
- height = defaultHeight,
- name,
- style,
- width = defaultWidth,
- ...interactiveProps
- },
- ref,
- ) => {
- const elementRef = useRef<HTMLDivElement>(null);
- const [fontLoaded, setFontLoaded] = useState(false);
-
- useImperativeHandle(ref, () => elementRef.current as HTMLDivElement, []);
-
- useEffect(() => {
- waitUntilDone()
- .then(() => {
- setFontLoaded(true);
- })
- .catch((error) => {
- cancelRender(
- error instanceof Error ? error : new Error(String(error)),
- );
- });
- }, []);
+> = ({
+ captions,
+ combineTokensWithinMilliseconds = defaultCombineTokensWithinMilliseconds,
+ controls,
+ height = defaultHeight,
+ name,
+ style,
+ width = defaultWidth,
+ ...interactiveProps
+}) => {
+ const [fontLoaded, setFontLoaded] = useState(false);
+
+ useEffect(() => {
+ waitUntilDone()
+ .then(() => {
+ setFontLoaded(true);
+ })
+ .catch((error) => {
+ cancelRender(error instanceof Error ? error : new Error(String(error)));
+ });
+ }, []);
- return (
- <Sequence
- layout="none"
- {...interactiveProps}
- controls={controls}
- name={name ?? '<MovingPillCaptions>'}
+ return (
+ <Sequence
+ layout="none"
+ {...interactiveProps}
+ controls={controls}
+ name={name ?? '<MovingPillCaptions>'}
+ >
+ <div
+ style={{
+ height,
+ marginInline: 'auto',
+ width,
+ ...style,
+ }}
>
- <div
- ref={elementRef}
- style={{
- height,
- marginInline: 'auto',
- width,
- ...style,
- }}
- >
- <MovingPillCaptionsContent
- captionAreaWidth={width ?? null}
- captions={captions}
- combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}
- fontLoaded={fontLoaded}
- />
- </div>
- </Sequence>
- );
- },
-);
+ <MovingPillCaptionsContent
+ captionAreaWidth={width ?? null}
+ captions={captions}
+ combineTokensWithinMilliseconds={combineTokensWithinMilliseconds}
+ fontLoaded={fontLoaded}
+ />
+ </div>
+ </Sequence>
+ );
+};
const MovingPillCaptionsLayer = Interactive.withSchema({
Component: MovingPillCaptionsInner,
diff --git a/packages/example/src/oscilloscope.element.tsx b/packages/example/src/oscilloscope.element.tsx
index 276e3af546..ac8aecb2f6 100644
--- a/packages/example/src/oscilloscope.element.tsx
+++ b/packages/example/src/oscilloscope.element.tsx
@@ -4,7 +4,7 @@ import {
getWaveformPortion,
useWindowedAudioData,
} from '@remotion/media-utils';
-import React, {forwardRef, useImperativeHandle, useRef} from 'react';
+import React from 'react';
import {
Interactive,
Sequence,
@@ -74,18 +74,9 @@ const AudioOscilloscopeContent: React.FC<{
readonly audioSrc: string;
readonly lineColor: string;
readonly lineWidth: number;
- readonly elementRef: React.RefObject<HTMLDivElement | null>;
readonly style: AudioOscilloscopeProps['style'];
readonly windowInSeconds: number;
-}> = ({
- amplitude,
- audioSrc,
- lineColor,
- lineWidth,
- elementRef,
- style,
- windowInSeconds,
-}) => {
+}> = ({amplitude, audioSrc, lineColor, lineWidth, style, windowInSeconds}) => {
const frame = useCurrentFrame();
const {fps} = useVideoConfig();
const {audioData, dataOffsetInSeconds} = useWindowedAudioData({
@@ -116,7 +107,6 @@ const AudioOscilloscopeContent: React.FC<{
return (
<div
- ref={elementRef}
style={{
boxSizing: 'border-box',
height: 300,
@@ -151,48 +141,37 @@ const AudioOscilloscopeContent: React.FC<{
);
};
-const AudioOscilloscopeInner = forwardRef<
- HTMLDivElement,
+const AudioOscilloscopeInner: React.FC<
AudioOscilloscopeProps & {readonly controls: SequenceControls | undefined}
->(
- (
- {
- amplitude = 2,
- audioSrc = 'https://remotion.media/elements/remotion-made-this-picture-move.mp3',
- controls,
- lineColor = '#55e6ff',
- lineWidth = 6,
- name,
- style,
- windowInSeconds = 0.35,
- ...sequenceProps
- },
- ref,
- ) => {
- const elementRef = useRef<HTMLDivElement>(null);
-
- useImperativeHandle(ref, () => elementRef.current as HTMLDivElement, []);
-
- return (
- <Sequence
- layout="none"
- {...sequenceProps}
- controls={controls}
- name={name ?? 'Audio oscilloscope'}
- >
- <AudioOscilloscopeContent
- amplitude={amplitude}
- audioSrc={audioSrc}
- lineColor={lineColor}
- lineWidth={lineWidth}
- elementRef={elementRef}
- style={style}
- windowInSeconds={windowInSeconds}
- />
- </Sequence>
- );
- },
-);
+> = ({
+ amplitude = 2,
+ audioSrc = 'https://remotion.media/elements/remotion-made-this-picture-move.mp3',
+ controls,
+ lineColor = '#55e6ff',
+ lineWidth = 6,
+ name,
+ style,
+ windowInSeconds = 0.35,
+ ...sequenceProps
+}) => {
+ return (
+ <Sequence
+ layout="none"
+ {...sequenceProps}
+ controls={controls}
+ name={name ?? 'Audio oscilloscope'}
+ >
+ <AudioOscilloscopeContent
+ amplitude={amplitude}
+ audioSrc={audioSrc}
+ lineColor={lineColor}
+ lineWidth={lineWidth}
+ style={style}
+ windowInSeconds={windowInSeconds}
+ />
+ </Sequence>
+ );
+};
export const AudioOscilloscope = Interactive.withSchema({
Component: AudioOscilloscopeInner,
diff --git a/packages/jonnys-videos/src/components/AnimatedCaptions.tsx b/packages/jonnys-videos/src/components/AnimatedCaptions.tsx
index a39ed83b02..ae423e5a1f 100644
--- a/packages/jonnys-videos/src/components/AnimatedCaptions.tsx
+++ b/packages/jonnys-videos/src/components/AnimatedCaptions.tsx
@@ -4,10 +4,8 @@ import {glow} from '@remotion/effects/glow';
import {radialProgressiveBlur} from '@remotion/effects/radial-progressive-blur';
import {Audio} from '@remotion/media';
import React, {
- forwardRef,
useCallback,
useEffect,
- useImperativeHandle,
useLayoutEffect,
useMemo,
useRef,
@@ -438,10 +436,9 @@ const FetchedAnimatedCaptions: React.FC<{
);
};
-const AnimatedCaptionsInner = forwardRef<
- HTMLDivElement,
+const AnimatedCaptionsInner: React.FC<
AnimatedCaptionsProps & {readonly controls: SequenceControls | undefined}
->((props, ref) => {
+> = (props) => {
const {
captions,
captionsSrc,
@@ -450,10 +447,6 @@ const AnimatedCaptionsInner = forwardRef<
voiceoverSrc,
...interactiveProps
} = props;
- const elementRef = useRef<HTMLDivElement>(null);
-
- useImperativeHandle(ref, () => elementRef.current as HTMLDivElement, []);
-
return (
<Sequence
layout="none"
@@ -461,7 +454,7 @@ const AnimatedCaptionsInner = forwardRef<
controls={controls}
name={name ?? '<AnimatedCaptions>'}
>
- <AbsoluteFill ref={elementRef}>
+ <AbsoluteFill>
{captions ? (
<AnimatedCaptionsContent
captions={captions}
@@ -476,7 +469,7 @@ const AnimatedCaptionsInner = forwardRef<
</AbsoluteFill>
</Sequence>
);
-});
+};
export const AnimatedCaptions = Interactive.withSchema({
Component: AnimatedCaptionsInner,
diff --git a/packages/maptiler/src/MapOverlay.tsx b/packages/maptiler/src/MapOverlay.tsx
index be38d8aa09..6cb502cfcd 100644
--- a/packages/maptiler/src/MapOverlay.tsx
+++ b/packages/maptiler/src/MapOverlay.tsx
@@ -1,11 +1,4 @@
-import {
- forwardRef,
- useContext,
- useImperativeHandle,
- useRef,
- type ForwardRefRenderFunction,
- type ReactNode,
-} from 'react';
+import {useContext, type FC, type ReactNode} from 'react';
import {
Interactive,
Freeze,
@@ -109,40 +102,33 @@ const mapOverlaySchema = {
...Interactive.transformSchema,
} as const satisfies InteractivitySchema;
-const MapOverlayRefForwardingFunction: ForwardRefRenderFunction<
- HTMLDivElement,
- MapOverlayProps
-> = (
- {
- anchor = 'center',
- children,
- latitude,
- longitude,
- offsetX = 0,
- offsetY = 0,
- opacity = 1,
- rotation = 0,
- rotationAlignment = 'viewport',
- style,
- durationInFrames,
- from,
- premountFor,
- postmountFor,
- styleWhilePremounted,
- styleWhilePostmounted,
- trimBefore,
- playbackRate,
- loop,
- freeze,
- hidden,
- name,
- showInTimeline,
- controls,
- },
- ref,
-) => {
+const MapOverlayInner: FC<MapOverlayProps> = ({
+ anchor = 'center',
+ children,
+ latitude,
+ longitude,
+ offsetX = 0,
+ offsetY = 0,
+ opacity = 1,
+ rotation = 0,
+ rotationAlignment = 'viewport',
+ style,
+ durationInFrames,
+ from,
+ premountFor,
+ postmountFor,
+ styleWhilePremounted,
+ styleWhilePostmounted,
+ trimBefore,
+ playbackRate,
+ loop,
+ freeze,
+ hidden,
+ name,
+ showInTimeline,
+ controls,
+}) => {
const {map} = useContext(MapTilerContext);
- const elementRef = useRef<HTMLDivElement>(null);
const point = map?.project([longitude, latitude]);
const horizontalAnchor = anchor.includes('left')
? 0
@@ -155,8 +141,6 @@ const MapOverlayRefForwardingFunction: ForwardRefRenderFunction<
? -100
: -50;
- useImperativeHandle(ref, () => elementRef.current as HTMLDivElement, []);
-
const {
effectivePremountFor,
effectivePostmountFor,
@@ -199,7 +183,6 @@ const MapOverlayRefForwardingFunction: ForwardRefRenderFunction<
_remotionInternalIsPostmounting={postmountingActive}
>
<div
- ref={elementRef}
style={{
left: (point?.x ?? 0) + offsetX,
opacity,
@@ -219,8 +202,6 @@ const MapOverlayRefForwardingFunction: ForwardRefRenderFunction<
);
};
-const MapOverlayInner = forwardRef(MapOverlayRefForwardingFunction);
-
export const MapOverlay = Interactive.withSchema({
Component: MapOverlayInner,
componentName: '<MapOverlay>',
diff --git a/packages/maptiler/src/MapRegion.tsx b/packages/maptiler/src/MapRegion.tsx
index f30f7618e3..9fdc8ae089 100644
--- a/packages/maptiler/src/MapRegion.tsx
+++ b/packages/maptiler/src/MapRegion.tsx
@@ -1,16 +1,6 @@
import type {GeoJSONSource} from '@maptiler/sdk';
import {length as getLineLength, lineSliceAlong, lineString} from '@turf/turf';
-import {
- forwardRef,
- useContext,
- useEffect,
- useImperativeHandle,
- useMemo,
- useRef,
- useState,
- type ForwardRefRenderFunction,
- type RefObject,
-} from 'react';
+import {useContext, useEffect, useMemo, useState, type FC} from 'react';
import {
Interactive,
Freeze,
@@ -308,17 +298,13 @@ const MapRegionDrawing = ({
return null;
};
-const MapRegionBounds = ({
+const MapRegionBounds: FC<{readonly feature: MapRegionFeature}> = ({
feature,
- boundsRef,
-}: {
- readonly feature: MapRegionFeature;
- readonly boundsRef: RefObject<HTMLDivElement | null>;
}) => {
const {map} = useContext(MapTilerContext);
if (!map) {
- return <div ref={boundsRef} />;
+ return <div />;
}
const points = feature.geometry.coordinates
@@ -331,7 +317,6 @@ const MapRegionBounds = ({
return (
<div
- ref={boundsRef}
style={{
height: bottom - top,
left,
@@ -346,38 +331,28 @@ const MapRegionBounds = ({
);
};
-const MapRegionRefForwardingFunction: ForwardRefRenderFunction<
- HTMLDivElement,
- MapRegionProps
-> = (
- {
- feature,
- fill = 0,
- fillColor,
- glow = 0.72,
- id,
- progress = 1,
- strokeColor = '#8f1712',
- strokeWidth = 9,
- durationInFrames,
- from,
- premountFor,
- postmountFor,
- trimBefore,
- playbackRate,
- loop,
- freeze,
- hidden,
- name,
- showInTimeline,
- controls,
- },
- ref,
-) => {
- const boundsRef = useRef<HTMLDivElement>(null);
-
- useImperativeHandle(ref, () => boundsRef.current as HTMLDivElement, []);
-
+const MapRegionInner: FC<MapRegionProps> = ({
+ feature,
+ fill = 0,
+ fillColor,
+ glow = 0.72,
+ id,
+ progress = 1,
+ strokeColor = '#8f1712',
+ strokeWidth = 9,
+ durationInFrames,
+ from,
+ premountFor,
+ postmountFor,
+ trimBefore,
+ playbackRate,
+ loop,
+ freeze,
+ hidden,
+ name,
+ showInTimeline,
+ controls,
+}) => {
const {
effectivePremountFor,
effectivePostmountFor,
@@ -429,15 +404,13 @@ const MapRegionRefForwardingFunction: ForwardRefRenderFunction<
strokeColor={strokeColor}
strokeWidth={strokeWidth}
/>
- <MapRegionBounds feature={feature} boundsRef={boundsRef} />
+ <MapRegionBounds feature={feature} />
</>
</Sequence>
</Freeze>
);
};
-const MapRegionInner = forwardRef(MapRegionRefForwardingFunction);
-
export const MapRegion = Interactive.withSchema({
Component: MapRegionInner,
componentName: '<MapRegion>',
diff --git a/packages/maptiler/src/MapRoute.tsx b/packages/maptiler/src/MapRoute.tsx
index d4db5cab7b..5ea89b71ef 100644
--- a/packages/maptiler/src/MapRoute.tsx
+++ b/packages/maptiler/src/MapRoute.tsx
@@ -1,16 +1,6 @@
import type {GeoJSONSource} from '@maptiler/sdk';
import {length as getLineLength, lineSliceAlong, lineString} from '@turf/turf';
-import {
- forwardRef,
- useContext,
- useEffect,
- useImperativeHandle,
- useMemo,
- useRef,
- useState,
- type ForwardRefRenderFunction,
- type RefObject,
-} from 'react';
+import {useContext, useEffect, useMemo, useState, type FC} from 'react';
import {
Interactive,
Freeze,
@@ -239,17 +229,11 @@ const MapRouteDrawing = ({
return null;
};
-const MapRouteBounds = ({
- feature,
- boundsRef,
-}: {
- readonly feature: MapRouteFeature;
- readonly boundsRef: RefObject<HTMLDivElement | null>;
-}) => {
+const MapRouteBounds: FC<{readonly feature: MapRouteFeature}> = ({feature}) => {
const {map} = useContext(MapTilerContext);
if (!map) {
- return <div ref={boundsRef} />;
+ return <div />;
}
const points = feature.geometry.coordinates.map(([longitude, latitude]) =>
@@ -262,7 +246,6 @@ const MapRouteBounds = ({
return (
<div
- ref={boundsRef}
style={{
height: bottom - top,
left,
@@ -277,36 +260,26 @@ const MapRouteBounds = ({
);
};
-const MapRouteRefForwardingFunction: ForwardRefRenderFunction<
- HTMLDivElement,
- MapRouteProps
-> = (
- {
- feature,
- glow = 0.72,
- id,
- progress = 1,
- strokeColor = '#006cff',
- strokeWidth = 9,
- durationInFrames,
- from,
- premountFor,
- postmountFor,
- trimBefore,
- playbackRate,
- loop,
- freeze,
- hidden,
- name,
- showInTimeline,
- controls,
- },
- ref,
-) => {
- const boundsRef = useRef<HTMLDivElement>(null);
-
- useImperativeHandle(ref, () => boundsRef.current as HTMLDivElement, []);
-
+const MapRouteInner: FC<MapRouteProps> = ({
+ feature,
+ glow = 0.72,
+ id,
+ progress = 1,
+ strokeColor = '#006cff',
+ strokeWidth = 9,
+ durationInFrames,
+ from,
+ premountFor,
+ postmountFor,
+ trimBefore,
+ playbackRate,
+ loop,
+ freeze,
+ hidden,
+ name,
+ showInTimeline,
+ controls,
+}) => {
const {
effectivePremountFor,
effectivePostmountFor,
@@ -356,15 +329,13 @@ const MapRouteRefForwardingFunction: ForwardRefRenderFunction<
strokeColor={strokeColor}
strokeWidth={strokeWidth}
/>
- <MapRouteBounds feature={feature} boundsRef={boundsRef} />
+ <MapRouteBounds feature={feature} />
</>
</Sequence>
</Freeze>
);
};
-const MapRouteInner = forwardRef(MapRouteRefForwardingFunction);
-
export const MapRoute = Interactive.withSchema({
Component: MapRouteInner,
componentName: '<MapRoute>',
diff --git a/packages/maptiler/src/MapViewport.tsx b/packages/maptiler/src/MapViewport.tsx
index be9a870ea8..dc9e28146f 100644
--- a/packages/maptiler/src/MapViewport.tsx
+++ b/packages/maptiler/src/MapViewport.tsx
@@ -1,19 +1,7 @@
import {Map as MapTilerMap, MapStyle, type MapOptions} from '@maptiler/sdk';
-import type {
- ComponentType,
- CSSProperties,
- ForwardRefRenderFunction,
- ReactNode,
-} from 'react';
+import type {ComponentType, CSSProperties, FC, ReactNode} from 'react';
import '@maptiler/sdk/style.css';
-import {
- forwardRef,
- useEffect,
- useImperativeHandle,
- useMemo,
- useRef,
- useState,
-} from 'react';
+import {useEffect, useMemo, useRef, useState} from 'react';
import {
Interactive,
Freeze,
@@ -219,41 +207,36 @@ const MissingApiKey = () => {
);
};
-const MapViewportContentRefForwardingFunction: ForwardRefRenderFunction<
- HTMLDivElement,
+const MapViewportContent: FC<
MapViewportProps & {
readonly premountingStyle: CSSProperties | null;
}
-> = (
- {
- apiKey,
- premountingStyle,
- backgroundColor = '#dfe7e2',
- bearing = 0,
- centerLatitude = 0,
- centerLongitude = 0,
- children,
- language,
- mapOptions,
- mapStyle = MapStyle.BASIC,
- onMapReady,
- paddingBottom = 0,
- paddingLeft = 0,
- paddingRight = 0,
- paddingTop = 0,
- pitch = 0,
- projection,
- showLabels = true,
- administrativeBorders = 'all',
- terrain = false,
- terrainExaggeration = 1,
- zoom = 4,
- },
- ref,
-) => {
+> = ({
+ apiKey,
+ premountingStyle,
+ backgroundColor = '#dfe7e2',
+ bearing = 0,
+ centerLatitude = 0,
+ centerLongitude = 0,
+ children,
+ language,
+ mapOptions,
+ mapStyle = MapStyle.BASIC,
+ onMapReady,
+ paddingBottom = 0,
+ paddingLeft = 0,
+ paddingRight = 0,
+ paddingTop = 0,
+ pitch = 0,
+ projection,
+ showLabels = true,
+ administrativeBorders = 'all',
+ terrain = false,
+ terrainExaggeration = 1,
+ zoom = 4,
+}) => {
const mapContainerRef = useRef<HTMLDivElement>(null);
const mapRef = useRef<MapTilerMap | null>(null);
- const viewportRef = useRef<HTMLDivElement>(null);
const initialCameraRef = useRef({
bearing,
centerLatitude,
@@ -292,8 +275,6 @@ const MapViewportContentRefForwardingFunction: ForwardRefRenderFunction<
[cameraRevision, map, styleRevision],
);
- useImperativeHandle(ref, () => viewportRef.current as HTMLDivElement, []);
-
useEffect(() => {
if (!apiKey) {
continueRender(loadingHandle);
@@ -514,7 +495,6 @@ const MapViewportContentRefForwardingFunction: ForwardRefRenderFunction<
return (
<div
- ref={viewportRef}
style={{
backgroundColor,
inset: 0,
@@ -543,30 +523,23 @@ const MapViewportContentRefForwardingFunction: ForwardRefRenderFunction<
);
};
-const MapViewportContent = forwardRef(MapViewportContentRefForwardingFunction);
-const MapViewportRefForwardingFunction: ForwardRefRenderFunction<
- HTMLDivElement,
- MapViewportProps
-> = (
- {
- durationInFrames,
- from,
- trimBefore,
- playbackRate,
- loop,
- freeze,
- hidden,
- name,
- showInTimeline,
- controls,
- premountFor,
- postmountFor,
- styleWhilePremounted,
- styleWhilePostmounted,
- ...props
- },
- ref,
-) => {
+const MapViewportInner: FC<MapViewportProps> = ({
+ durationInFrames,
+ from,
+ trimBefore,
+ playbackRate,
+ loop,
+ freeze,
+ hidden,
+ name,
+ showInTimeline,
+ controls,
+ premountFor,
+ postmountFor,
+ styleWhilePremounted,
+ styleWhilePostmounted,
+ ...props
+}) => {
const {
effectivePremountFor,
effectivePostmountFor,
@@ -609,18 +582,12 @@ const MapViewportRefForwardingFunction: ForwardRefRenderFunction<
_remotionInternalIsPremounting={premountingActive}
_remotionInternalIsPostmounting={postmountingActive}
>
- <MapViewportContent
- {...props}
- ref={ref}
- premountingStyle={premountingStyle}
- />
+ <MapViewportContent {...props} premountingStyle={premountingStyle} />
</Sequence>
</Freeze>
);
};
-const MapViewportInner = forwardRef(MapViewportRefForwardingFunction);
-
export const MapViewport: ComponentType<MapViewportProps> =
Interactive.withSchema({
Component: MapViewportInner,