Skip to content

🎥 Make videos programmatically with React

create global window variable

Rishi Raj Jain61aa98507dc0
diff --git a/packages/cli/src/editor/components/RenderModal/RenderModal.tsx b/packages/cli/src/editor/components/RenderModal/RenderModal.tsx
index c4e47da88f..fac9d9c5f8 100644
--- a/packages/cli/src/editor/components/RenderModal/RenderModal.tsx
+++ b/packages/cli/src/editor/components/RenderModal/RenderModal.tsx
@@ -737,7 +737,7 @@ const RenderModal: React.FC<
useEffect(() => {
const listenToChanges = () => {
- if (window.unsavedProps) {
+ if (window.remotion_unsavedProps) {
notificationCenter.current?.addNotification({
id: 'random',
content: 'Do not save hey',
diff --git a/packages/cli/src/editor/helpers/document-title.ts b/packages/cli/src/editor/helpers/document-title.ts
index f50ddf5838..90727d4c57 100644
--- a/packages/cli/src/editor/helpers/document-title.ts
+++ b/packages/cli/src/editor/helpers/document-title.ts
@@ -6,21 +6,13 @@ let unsavedProps = false;
let tabInactive = false;
let renderJobs: RenderJob[] = [];
-declare global {
- interface Window {
- unsavedProps: boolean;
- }
-}
-
export const setCurrentVideoId = (id: string | null) => {
currentVideoId = id;
updateTitle();
};
export const setUnsavedProps = (unsaved: boolean) => {
- if (typeof window !== 'undefined') {
- window.unsavedProps = unsaved;
- }
+ window.remotion_unsavedProps = unsaved;
unsavedProps = unsaved;
};
diff --git a/packages/cli/src/preview-server/error-overlay/react-overlay/listen-to-runtime-errors.ts b/packages/cli/src/preview-server/error-overlay/react-overlay/listen-to-runtime-errors.ts
index c55516a579..5b6ec8a934 100644
--- a/packages/cli/src/preview-server/error-overlay/react-overlay/listen-to-runtime-errors.ts
+++ b/packages/cli/src/preview-server/error-overlay/react-overlay/listen-to-runtime-errors.ts
@@ -73,7 +73,7 @@ const crashWithFrames = (crash: () => void) => (error: Error) => {
if (didHookOrderChange && !justRefreshedBecauseOfHooks) {
// eslint-disable-next-line no-console
console.log('Hook order changed. Reloading app...');
- if (window.unsavedProps) {
+ if (window.remotion_unsavedProps) {
notificationCenter.current?.addNotification({
id: 'random',
content: 'Do not save hey',
diff --git a/packages/cli/src/preview-server/hot-middleware/process-update.ts b/packages/cli/src/preview-server/hot-middleware/process-update.ts
index b5e66dd85b..c10237b4ba 100644
--- a/packages/cli/src/preview-server/hot-middleware/process-update.ts
+++ b/packages/cli/src/preview-server/hot-middleware/process-update.ts
@@ -170,7 +170,7 @@ export const processUpdate = function (
console.warn(
'[Fast refresh] Update check failed: ' + (err.stack || err.message)
);
- if (window.unsavedProps) {
+ if (window.remotion_unsavedProps) {
notificationCenter.current?.addNotification({
id: 'random',
content: 'Do not save hey',
@@ -189,7 +189,7 @@ export const processUpdate = function (
}
if (options.warn) console.warn('[Fast refresh] Reloading page');
- if (window.unsavedProps) {
+ if (window.remotion_unsavedProps) {
notificationCenter.current?.addNotification({
id: 'random',
content: 'Do not save hey',
diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts
index 1fcc45383f..0a4792d568 100644
--- a/packages/core/src/index.ts
+++ b/packages/core/src/index.ts
@@ -53,6 +53,7 @@ declare global {
siteVersion: '10';
remotion_version: string;
remotion_imported: string | boolean;
+ remotion_unsavedProps: boolean | null | undefined;
}
}