Skip to content

🎥 Make videos programmatically with React

`remotion`: Fix `useRemotionEnvironment().isStudio` detection

Jonny Burger3db8ba2c8429
diff --git a/packages/studio/src/Studio.tsx b/packages/studio/src/Studio.tsx
index 91e6d4ea88..e2769055d7 100644
--- a/packages/studio/src/Studio.tsx
+++ b/packages/studio/src/Studio.tsx
@@ -14,17 +14,6 @@ export const Studio: React.FC<{
readonly rootComponent: React.FC;
readonly readOnly: boolean;
}> = ({rootComponent, readOnly}) => {
- useLayoutEffect(() => {
- window.remotion_isStudio = true;
- window.remotion_isReadOnlyStudio = readOnly;
- Internals.enableSequenceStackTraces();
-
- return () => {
- window.remotion_isStudio = false;
- window.remotion_isReadOnlyStudio = false;
- };
- }, [readOnly]);
-
useLayoutEffect(() => {
injectCSS();
}, []);
diff --git a/packages/studio/src/previewEntry.tsx b/packages/studio/src/previewEntry.tsx
index 563a24c8ac..255590139e 100644
--- a/packages/studio/src/previewEntry.tsx
+++ b/packages/studio/src/previewEntry.tsx
@@ -45,6 +45,10 @@ const renderToDOM = (content: React.ReactElement) => {
renderToDOM(<NoRegisterRoot />);
Internals.waitForRoot((NewRoot) => {
+ window.remotion_isStudio = true;
+ window.remotion_isReadOnlyStudio = false;
+ Internals.enableSequenceStackTraces();
+
renderToDOM(<Studio readOnly={false} rootComponent={NewRoot} />);
});
diff --git a/packages/studio/src/renderEntry.tsx b/packages/studio/src/renderEntry.tsx
index b1315a78bd..bf0d71b143 100644
--- a/packages/studio/src/renderEntry.tsx
+++ b/packages/studio/src/renderEntry.tsx
@@ -279,6 +279,10 @@ const renderContent = (Root: React.FC) => {
);
import('./internals')
.then(({StudioInternals}) => {
+ window.remotion_isStudio = true;
+ window.remotion_isReadOnlyStudio = true;
+
+ Internals.enableSequenceStackTraces();
renderToDOM(<StudioInternals.Studio readOnly rootComponent={Root} />);
})
.catch((err) => {