Skip to content

🎥 Make videos programmatically with React

`@remotion/lottie`: Continue the render if component unmounts

Jonny Burger218df7245aea
diff --git a/packages/lottie/src/Lottie.tsx b/packages/lottie/src/Lottie.tsx
index f40283301e..e9b8d07190 100644
--- a/packages/lottie/src/Lottie.tsx
+++ b/packages/lottie/src/Lottie.tsx
@@ -43,6 +43,14 @@ export const Lottie = ({
const [handle] = useState(() =>
delayRender('Waiting for Lottie animation to load'),
);
+
+ // If component unmounts, continue the render
+ useEffect(() => {
+ return () => {
+ continueRender(handle);
+ };
+ }, [handle]);
+
const frame = useCurrentFrame();
currentFrameRef.current = frame;