Skip to content

🎥 Make videos programmatically with React

Update offthread-video-while-rendering.mdx

Tom Howe9aa697eeaa37
diff --git a/packages/docs/docs/miscellaneous/snippets/offthread-video-while-rendering.mdx b/packages/docs/docs/miscellaneous/snippets/offthread-video-while-rendering.mdx
index c49e3b8aa7..82ded227b8 100644
--- a/packages/docs/docs/miscellaneous/snippets/offthread-video-while-rendering.mdx
+++ b/packages/docs/docs/miscellaneous/snippets/offthread-video-while-rendering.mdx
@@ -9,30 +9,30 @@ This is useful for attaching a `ref` to the [`<Video />`](/docs/video) tag.
```tsx twoslash
-// @noErrors
-import { forwardRef } from "react";
+import { forwardRef } from 'react';
import {
getRemotionEnvironment,
OffthreadVideo,
RemotionOffthreadVideoProps,
Video,
-} from "remotion";
+} from 'remotion';
-const OffthreadWhileRenderingRefForwardingFunction: React.ForwardRefRenderFunction<
- HTMLVideoElement,
- RemotionOffthreadVideoProps
-> = (props, ref) => {
- const { imageFormat, ...otherProps } = props;
+function OffthreadWhileRenderingRefForwardingFunction(
+ props: RemotionOffthreadVideoProps,
+ ref: React.Ref<HTMLVideoElement>,
+) {
+ const { onAutoPlayError, ...otherProps } = props;
const isPreview = !getRemotionEnvironment().isRendering;
+ const onAutoPlayErrorNotNull = onAutoPlayError ?? undefined;
if (isPreview) {
- return <Video ref={ref} {...otherProps}></Video>;
+ return <Video ref={ref} onAutoPlayError={onAutoPlayErrorNotNull} {...otherProps} />;
}
- return <OffthreadVideo {...props}></OffthreadVideo>;
-};
+ return <OffthreadVideo onAutoPlayError={onAutoPlayError} {...props} />;
+}
export const OffthreadVideoWhileRendering = forwardRef(
- OffthreadWhileRenderingRefForwardingFunction
+ OffthreadWhileRenderingRefForwardingFunction,
);
```