Skip to content

🎥 Make videos programmatically with React

Skip caching frame when premounting

Jonny Burger1487e864b764
diff --git a/packages/media/src/video/video-for-preview.tsx b/packages/media/src/video/video-for-preview.tsx
index 713f6ddc18..168b1be31e 100644
--- a/packages/media/src/video/video-for-preview.tsx
+++ b/packages/media/src/video/video-for-preview.tsx
@@ -209,6 +209,8 @@ const VideoForPreviewAssertedShowing: React.FC<
const initialDurationInFrames = useRef(videoConfig.durationInFrames);
const initialSequenceOffset = useRef(sequenceOffset);
const hasDrawnRealFrameRef = useRef(false);
+ const isPremountingRef = useRef(isPremounting);
+ isPremountingRef.current = isPremounting;
useLayoutEffect(() => {
if (!seamlessTransition) {
@@ -246,7 +248,11 @@ const VideoForPreviewAssertedShowing: React.FC<
const canvas = canvasRef.current;
return () => {
- if (!canvas || !hasDrawnRealFrameRef.current) {
+ if (
+ !canvas ||
+ !hasDrawnRealFrameRef.current ||
+ isPremountingRef.current
+ ) {
return;
}