Skip to content

🎥 Make videos programmatically with React

throw if renderFrames() called with invalid composition name

Jonny Burger8f7758d167a5
diff --git a/packages/bundler/src/renderEntry.tsx b/packages/bundler/src/renderEntry.tsx
index cbe3c41719..f9d33568b5 100644
--- a/packages/bundler/src/renderEntry.tsx
+++ b/packages/bundler/src/renderEntry.tsx
@@ -48,13 +48,15 @@ const GetVideo = () => {
}
if (!video && compositions.compositions.length > 0) {
- compositions.setCurrentComposition(
- (
- compositions.compositions.find(
- (c) => c.id === Internals.getCompositionName()
- ) as TComposition
- )?.id ?? null
- );
+ const foundComposition = compositions.compositions.find(
+ (c) => c.id === Internals.getCompositionName()
+ ) as TComposition;
+ if (!foundComposition) {
+ throw new Error(
+ 'Found no composition with the name ' + Internals.getCompositionName()
+ );
+ }
+ compositions.setCurrentComposition(foundComposition?.id ?? null);
}
}, [compositions, compositions.compositions, video]);