Skip to content

🎥 Make videos programmatically with React

add a warning once

Jonny Burger25039c0b5338
diff --git a/packages/core/src/config/input-props.ts b/packages/core/src/config/input-props.ts
index 1d66eda7bc..f05032f407 100644
--- a/packages/core/src/config/input-props.ts
+++ b/packages/core/src/config/input-props.ts
@@ -2,9 +2,25 @@ import {getRemotionEnvironment} from '../get-environment';
export const INPUT_PROPS_KEY = 'remotion.inputProps';
+let didWarnSSRImport = false;
+
+const warnOnceSSRImport = () => {
+ if (didWarnSSRImport) {
+ return;
+ }
+
+ didWarnSSRImport = true;
+ console.warn(
+ 'Called `getInputProps()` on the server. This function is not available server-side and has returned an empty object.'
+ );
+ console.warn("To hide this warning, don't call this function on the server:");
+ console.warn(" typeof window === 'undefined' ? {} : getInputProps()");
+};
+
export const getInputProps = () => {
if (getRemotionEnvironment() === 'rendering') {
if (typeof window === 'undefined') {
+ warnOnceSSRImport();
return {};
}
@@ -18,7 +34,7 @@ export const getInputProps = () => {
}
if (getRemotionEnvironment() === 'preview') {
- return (process.env.INPUT_PROPS as unknown) as object | null;
+ return process.env.INPUT_PROPS as unknown as object | null;
}
throw new Error(