Skip to content

🎥 Make videos programmatically with React

Update OffthreadVideoForRendering.tsx

Jonny Burger152f169b37d9
diff --git a/packages/core/src/video/OffthreadVideoForRendering.tsx b/packages/core/src/video/OffthreadVideoForRendering.tsx
index a6fb7e9d9b..2fc57a9045 100644
--- a/packages/core/src/video/OffthreadVideoForRendering.tsx
+++ b/packages/core/src/video/OffthreadVideoForRendering.tsx
@@ -1,10 +1,4 @@
-import React, {
- useCallback,
- useContext,
- useEffect,
- useMemo,
- useState,
-} from 'react';
+import React, {useCallback, useContext, useEffect, useMemo} from 'react';
import {getAbsoluteSrc} from '../absolute-src';
import {
useFrameForVolumeProp,
@@ -38,8 +32,6 @@ export const OffthreadVideoForRendering: React.FC<OffthreadVideoProps> = ({
const {registerAsset, unregisterAsset} = useContext(CompositionManager);
- const [crash, setCrash] = useState(false);
-
if (!src) {
throw new TypeError('No `src` was passed to <OffthreadVideo>.');
}
@@ -123,30 +115,10 @@ export const OffthreadVideoForRendering: React.FC<OffthreadVideoProps> = ({
const onErr: React.ReactEventHandler<HTMLVideoElement | HTMLImageElement> =
useCallback(
(e) => {
- console.log('ERROR', actualSrc);
- fetch(actualSrc)
- .then((res) => {
- console.log('fetch', res.status);
- return res.text();
- })
- .then((text) => {
- console.log('TEXT', text);
- })
- .catch((err) => {
- console.log('MSG', err.message);
- })
- .finally(() => {
- setCrash(true);
- });
-
onError?.(e);
},
- [actualSrc, onError]
+ [onError]
);
- if (crash) {
- throw new Error('crash');
- }
-
return <Img src={actualSrc} {...props} onError={onErr} />;
};