🎥 Make videos programmatically with React
Address default props docs review comments
Cursor Agentfef59bbb8810
diff --git a/packages/docs/docs/troubleshooting/cannot-save-default-props.mdx b/packages/docs/docs/troubleshooting/cannot-save-default-props.mdxindex 845a61d8d1..01e24aad44 100644--- a/packages/docs/docs/troubleshooting/cannot-save-default-props.mdx+++ b/packages/docs/docs/troubleshooting/cannot-save-default-props.mdx@@ -23,14 +23,15 @@ For that to work, Remotion needs to find the root file and extract the existingThis warning appears if one of these conditions is true:- The composition has no `defaultProps` prop.-- The composition ID is not hardcoded as a string.-- The `defaultProps` value is not a hardcoded object literal.+- The `id` is not a JSX string literal.+- The `defaultProps` value is not an inline object literal.- The root file cannot be found from the entry point or the known root file paths.- The root file is not TypeScript.## How to fix it-Put the composition in a root file that Remotion can find, and hardcode the `id` and `defaultProps` values:+Put the composition in a TypeScript root file that Remotion can find.+The `id` must be a JSX string literal and `defaultProps` must be an inline object literal:```tsx title="Root.tsx"import {Composition} from 'remotion';@@ -54,7 +55,7 @@ export const RemotionRoot = () => {};```-Avoid values that need runtime evaluation:+Avoid values that are not written in the required JSX shape:```tsx title="Root.tsx"import {Composition} from 'remotion';@@ -71,20 +72,18 @@ export const RemotionRoot = () => {## Root file paths-Remotion can automatically find a root file at these paths:+For saving default props, Remotion can automatically find TypeScript root files at these paths:- `src/Root.tsx`-- `src/Root.jsx`- `remotion/Root.tsx`-- `remotion/Root.jsx`- `app/remotion/Root.tsx`- `src/Video.tsx`-- `src/Video.jsx`- `src/remotion/Root.tsx`-- `src/remotion/Root.jsx`-If your entry point ends in `-entry`, Remotion also looks for a matching PascalCase root next to it.-For example, `gold-star-entry.tsx` maps to `GoldStarRoot.tsx`.+Remotion Studio may also discover JavaScript root files, but saving default props requires TypeScript.++If your entry point ends in `-entry`, Remotion also looks for a matching PascalCase root file next to it.+For example, `gold-star-entry.tsx` maps to `GoldStarRoot.tsx` or `GoldStarRoot.ts`.## AI agent prompt@@ -93,7 +92,7 @@ Use this prompt to resolve the warning:```txtRemotion Studio shows "Can't save default props" for my composition.Find the root file that registers the composition, then make the composition id and defaultProps statically analyzable.-The id should be a hardcoded string and defaultProps should be an inline object literal on the <Composition> or <Still>.+The id should be a JSX string literal and defaultProps should be an inline object literal on the <Composition> or <Still>.Preserve the current prop values and keep the composition behavior unchanged.```diff --git a/packages/studio/src/components/NewComposition/ValidationMessage.tsx b/packages/studio/src/components/NewComposition/ValidationMessage.tsxindex 0fd71f373a..5ed2a2968d 100644--- a/packages/studio/src/components/NewComposition/ValidationMessage.tsx+++ b/packages/studio/src/components/NewComposition/ValidationMessage.tsx@@ -28,7 +28,7 @@ const label: React.CSSProperties = {};export const ValidationMessage: React.FC<{- readonly message: React.ReactNode;+ readonly message: string;readonly align: 'flex-start' | 'flex-end';readonly type: 'warning' | 'error';readonly action?: React.ReactNode;diff --git a/packages/studio/src/test/render-modal-warnings.test.ts b/packages/studio/src/test/render-modal-warnings.test.tsindex 45bdb2431a..676ef1298c 100644--- a/packages/studio/src/test/render-modal-warnings.test.ts+++ b/packages/studio/src/test/render-modal-warnings.test.ts@@ -48,3 +48,46 @@ test('Does not add warnings before default props saveability is determined', ()expect(warnings).toStrictEqual([]);});++test('Keeps other warnings as stable entries without Resolve links', () => {+ const warnings = getRenderModalWarnings({+ cliProps: {title: 'Hello'},+ canSaveDefaultProps: {+ canUpdate: true,+ },+ isCustomDateUsed: true,+ customFileUsed: true,+ jsMapUsed: true,+ jsSetUsed: true,+ inJSONEditor: true,+ propsEditType: 'default-props',+ });++ expect(warnings).toStrictEqual([+ {+ id: 'input-props-override',+ message:+ 'The data that was passed using --props takes priority over the data you enter here.',+ },+ {+ id: 'custom-date-used',+ message:+ 'There is a Date in the schema which was serialized. Note the custom syntax.',+ },+ {+ id: 'static-file-used',+ message:+ 'There is a staticFile() in the schema which was serialized. Note the custom syntax.',+ },+ {+ id: 'map-used',+ message:+ 'A `Map` was used in the schema which can not be serialized to JSON.',+ },+ {+ id: 'set-used',+ message:+ 'A `Set` was used in the schema which can not be serialized to JSON.',+ },+ ]);+});