🎥 Make videos programmatically with React
Update RemotionRoot.tsx
Jonny Burger1fcf192d9c86
diff --git a/packages/core/src/RemotionRoot.tsx b/packages/core/src/RemotionRoot.tsxindex 4e563f3348..7b7f1e3ad2 100644--- a/packages/core/src/RemotionRoot.tsx+++ b/packages/core/src/RemotionRoot.tsx@@ -53,14 +53,13 @@ export const RemotionRoot: React.FC<{window.remotion_attempt = attempt;const id = delayRender(`Setting the current frame to ${f}`);- let avoidUpdate = false;+ let asyncUpdate = true;setFrame((s) => {const currentFrame = s[composition] ?? window.remotion_initialFrame;// Avoid cloning the objectif (currentFrame === f) {- avoidUpdate = true;- continueRender(id);+ asyncUpdate = false;return s;}@@ -69,8 +68,12 @@ export const RemotionRoot: React.FC<{[composition]: f,};});- if (!avoidUpdate) {++ // After setting the state, need to wait until it is applied in the next cycle+ if (asyncUpdate) {requestAnimationFrame(() => continueRender(id));+ } else {+ continueRender(id);}};