Skip to content

🎥 Make videos programmatically with React

Remotion 5.0: `<Series>` is a `<Sequence>` itself

Jonny Burgerf67a394f461c
diff --git a/packages/core/src/series/index.tsx b/packages/core/src/series/index.tsx
index 4dbda21419..063b40e0ff 100644
--- a/packages/core/src/series/index.tsx
+++ b/packages/core/src/series/index.tsx
@@ -1,8 +1,9 @@
import type {FC, PropsWithChildren} from 'react';
-import {Children, forwardRef, useMemo} from 'react';
+import React, {Children, forwardRef, useMemo} from 'react';
import type {LayoutAndStyle, SequenceProps} from '../Sequence.js';
import {Sequence} from '../Sequence.js';
import {addSequenceStackTraces} from '../enable-sequence-stack-traces.js';
+import {ENABLE_V5_BREAKING_CHANGES} from '../v5-flag.js';
import {validateDurationInFrames} from '../validation/validate-duration-in-frames.js';
import {flattenChildren} from './flatten-children.js';
import {
@@ -13,9 +14,9 @@ import {
type SeriesSequenceProps = PropsWithChildren<
{
- durationInFrames: number;
- offset?: number;
- className?: string;
+ readonly durationInFrames: number;
+ readonly offset?: number;
+ readonly className?: string;
} & Pick<SequenceProps, 'layout' | 'name'> &
LayoutAndStyle
>;
@@ -33,18 +34,26 @@ const SeriesSequenceRefForwardingFunction: React.ForwardRefRenderFunction<
const SeriesSequence = forwardRef(SeriesSequenceRefForwardingFunction);
+type V4Props = {
+ children: React.ReactNode;
+};
+
+type V5Props = SequenceProps;
+
+type SeriesProps = true extends typeof ENABLE_V5_BREAKING_CHANGES
+ ? V5Props
+ : V4Props;
+
/**
* @description with this component, you can easily stitch together scenes that should play sequentially after another.
* @see [Documentation](https://www.remotion.dev/docs/series)
*/
-const Series: FC<{
- children: React.ReactNode;
-}> & {
+const Series: FC<SeriesProps> & {
Sequence: typeof SeriesSequence;
-} = ({children}) => {
+} = (props) => {
const childrenValue = useMemo(() => {
let startFrame = 0;
- const flattenedChildren = flattenChildren(children);
+ const flattenedChildren = flattenChildren(props.children);
return Children.map(flattenedChildren, (child, i) => {
const castedChild = child as unknown as
| {
@@ -130,7 +139,15 @@ const Series: FC<{
</Sequence>
);
});
- }, [children]);
+ }, [props.children]);
+
+ if (ENABLE_V5_BREAKING_CHANGES) {
+ return (
+ <IsInsideSeriesContainer>
+ <Sequence {...props}>{childrenValue}</Sequence>
+ </IsInsideSeriesContainer>
+ );
+ }
return <IsInsideSeriesContainer>{childrenValue}</IsInsideSeriesContainer>;
};