Skip to content

🎥 Make videos programmatically with React

derive an example where throwing error does not work

Jonny Burger5a91a1907680
diff --git a/packages/example/src/CancelRender/index.tsx b/packages/example/src/CancelRender/index.tsx
index d5e1ca1e5b..07f692a180 100644
--- a/packages/example/src/CancelRender/index.tsx
+++ b/packages/example/src/CancelRender/index.tsx
@@ -1,8 +1,27 @@
-import React from 'react';
-import {AbsoluteFill, cancelRender, useCurrentFrame} from 'remotion';
+import React, {useEffect, useState} from 'react';
+import {
+ AbsoluteFill,
+ cancelRender,
+ delayRender,
+ useCurrentFrame,
+} from 'remotion';
-export const BaseRender: React.FC = () => {
+export const CancelRender: React.FC = () => {
const frame = useCurrentFrame();
+ useState(() => delayRender('Rendering...'));
+
+ useEffect(() => {
+ Promise.resolve()
+ .then(() => {
+ // Worst case: Inside a promise without a catch handler
+ // and with a timeout running
+ cancelRender(null);
+ })
+ // And then with a catch handler
+ .catch((err) => {
+ console.log(err);
+ });
+ }, []);
return (
<AbsoluteFill
diff --git a/packages/example/src/Video.tsx b/packages/example/src/Video.tsx
index 2f1a348dd0..fa7428759d 100644
--- a/packages/example/src/Video.tsx
+++ b/packages/example/src/Video.tsx
@@ -3,7 +3,7 @@ import React from 'react';
import {Composition, Folder, getInputProps, Still} from 'remotion';
import {TwentyTwoKHzAudio} from './22KhzAudio';
import BetaText from './BetaText';
-import {BaseRender} from './CancelRender';
+import {CancelRender} from './CancelRender';
import {ColorInterpolation} from './ColorInterpolation';
import {MyCtx, WrappedInContext} from './Context';
import CorruptVideo from './CorruptVideo';
@@ -64,7 +64,7 @@ export const Index: React.FC = () => {
id="cancel-render"
width={920}
height={720}
- component={BaseRender}
+ component={CancelRender}
durationInFrames={100}
/>
<Composition