Skip to content

🎥 Make videos programmatically with React

update stuff

Jonny Burger30475ae3dd31
diff --git a/packages/docs/docs/register-root.md b/packages/docs/docs/register-root.md
index 8cdcfcb05b..5c8248ca5c 100644
--- a/packages/docs/docs/register-root.md
+++ b/packages/docs/docs/register-root.md
@@ -65,7 +65,7 @@ export const RemotionRoot = () => {
## Defer registerRoot()
-In some cases, such as dynamically importing roots or loading WebAssembly, you might want to defer the loading of registerRoot(). If you are doing that, you need to tell Remotion to wait by using the [`delayRender()` / `continueRender()`](/docs/delay-render) pattern.
+In some cases, such as dynamically importing roots or loading WebAssembly, you might want to defer the loading of registerRoot(). In newer versions of Remotion, you may do so, without having to invoke `delayRender()`.
```tsx twoslash
// @filename: ./Root.tsx
@@ -78,11 +78,8 @@ const loadWebAssembly = () => Promise.resolve();
import { continueRender, delayRender, registerRoot } from "remotion";
import { RemotionRoot } from "./Root";
-const wait = delayRender();
-
loadWebAssembly().then(() => {
registerRoot(RemotionRoot);
- continueRender(wait);
});
```
diff --git a/packages/docs/components/TableOfContents/studio.tsx b/packages/docs/docs/studio/TableOfContents.tsx
similarity index 63%
rename from packages/docs/components/TableOfContents/studio.tsx
rename to packages/docs/docs/studio/TableOfContents.tsx
index e1b63c0a86..6549dfd93d 100644
--- a/packages/docs/components/TableOfContents/studio.tsx
+++ b/packages/docs/docs/studio/TableOfContents.tsx
@@ -1,6 +1,6 @@
import React from "react";
-import { Grid } from "./Grid";
-import { TOCItem } from "./TOCItem";
+import { Grid } from "../../components/TableOfContents/Grid";
+import { TOCItem } from "../../components/TableOfContents/TOCItem";
export const TableOfContents: React.FC = () => {
return (
@@ -16,6 +16,10 @@ export const TableOfContents: React.FC = () => {
<strong>{"watchStaticFile()"}</strong>
<div>Listen to changes of a static file</div>
</TOCItem>
+ <TOCItem link="/docs/studio/save-default-props">
+ <strong>{"saveDefaultProps()"}</strong>
+ <div>Save default props to the root file</div>
+ </TOCItem>
</Grid>
</div>
);
diff --git a/packages/docs/docs/studio/api.mdx b/packages/docs/docs/studio/api.mdx
index 904a58ee98..b2f9e0940c 100644
--- a/packages/docs/docs/studio/api.mdx
+++ b/packages/docs/docs/studio/api.mdx
@@ -4,7 +4,7 @@ sidebar_label: "@remotion/studio"
title: "@remotion/studio"
---
-import { TableOfContents } from "../../components/TableOfContents/studio";
+import { TableOfContents } from "./TableOfContents";
You can install this package from NPM:
diff --git a/packages/docs/docs/studio/save-default-props.mdx b/packages/docs/docs/studio/save-default-props.mdx
index 86f948a632..ac2923fc7b 100644
--- a/packages/docs/docs/studio/save-default-props.mdx
+++ b/packages/docs/docs/studio/save-default-props.mdx
@@ -1,6 +1,91 @@
---
-title: getStaticFiles()
+image: /generated/articles-docs-studio-save-default-props.png
+title: saveDefaultProps()
crumb: "@remotion/studio"
---
-hi there
+# saveDefaultProps()<AvailableFrom v="4.0.147"/>
+
+Saves the [`defaultProps`](/docs/composition) for a [composition](/docs/terminology/composition) back to the [root file](/docs/terminology/root-file).
+
+## Examples
+
+```tsx twoslash title="Saving {color: 'green'} to Root.tsx"
+// @target: esnext
+import { saveDefaultProps } from "@remotion/studio";
+
+await saveDefaultProps({
+ compositionId: "my-composition",
+ defaultProps: () => {
+ return {
+ color: "green",
+ };
+ },
+});
+```
+
+You can access the saved default props to only override part of it (reducer-style):
+
+```tsx twoslash title="Accessing the saved default props"
+// @target: esnext
+import { saveDefaultProps } from "@remotion/studio";
+
+await saveDefaultProps({
+ compositionId: "my-composition",
+ defaultProps: ({ savedDefaultProps }) => {
+ return {
+ ...savedDefaultProps,
+ color: "green",
+ };
+ },
+});
+```
+
+If you modified props in the Props Editor (right sidebar in the Studio), you can also access the unsaved props from there, and for example save them:
+
+```tsx twoslash title="Save props from the Props Editor"
+// @target: esnext
+import { saveDefaultProps } from "@remotion/studio";
+
+await saveDefaultProps({
+ compositionId: "my-composition",
+ defaultProps: ({ unsavedDefaultProps }) => {
+ return unsavedDefaultProps;
+ },
+});
+```
+
+If you have a Zod schema, you can also access its runtime value:
+
+```tsx twoslash title="Save props from the Props Editor"
+// @target: esnext
+import { saveDefaultProps } from "@remotion/studio";
+
+await saveDefaultProps({
+ compositionId: "my-composition",
+ defaultProps: ({ schema, unsavedDefaultProps }) => {
+ // Do something with the Zod schema
+
+ return {
+ ...unsavedDefaultProps,
+ color: "red",
+ };
+ },
+});
+```
+
+## Requirements
+
+In order to use this function:
+
+<Step>1</Step> You need to be inside the Remotion Studio.
+<br />
+<Step>2</Step> <code>zod</code> needs to be installed.
+<br />
+<br />
+
+Otherwise, the function will throw.
+
+## See also
+
+- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/studio/src/api/save-default-props.ts)
diff --git a/packages/docs/docs/terminology/root-file.mdx b/packages/docs/docs/terminology/root-file.mdx
new file mode 100644
index 0000000000..1121a713a2
--- /dev/null
+++ b/packages/docs/docs/terminology/root-file.mdx
@@ -0,0 +1,12 @@
+---
+image: /generated/articles-docs-terminology-root-file.png
+title: Root file
+crumb: "Terminology"
+---
+
+The Root file is the file that exports the Root component, which renders one or more [`<Composition />`](/docs/composition) components.
+By default, it is `src/Root.tsx` or `remotion/Root.tsx` in most Remotion templates, but you may reorganize the files arbitrarily.
+
+The [entry point](/docs/terminology/entry-point) will import the Root file and register it with [`registerRoot()`](/docs/register-root)
+
+See the [Root file of the Hello World project](https://github.com/remotion-dev/template-helloworld/blob/main/src/Root.tsx) as an example.
diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.js
index e76ccaf397..428a8d391b 100644
--- a/packages/docs/sidebars.js
+++ b/packages/docs/sidebars.js
@@ -429,7 +429,11 @@ module.exports = {
type: "doc",
id: "studio/api",
},
- items: ["studio/get-static-files", "studio/watch-static-file"],
+ items: [
+ "studio/get-static-files",
+ "studio/watch-static-file",
+ "studio/save-default-props",
+ ],
},
{
type: "category",
@@ -817,6 +821,7 @@ module.exports = {
"terminology/cloud-run-url",
"terminology/service-name",
"terminology/entry-point",
+ "terminology/root-file",
"terminology/remotion-root",
"terminology/public-dir",
"terminology/serve-url",
diff --git a/packages/docs/src/data/articles.ts b/packages/docs/src/data/articles.ts
index 21aae5ec28..d89a0196de 100644
--- a/packages/docs/src/data/articles.ts
+++ b/packages/docs/src/data/articles.ts
@@ -2808,6 +2808,13 @@ export const articles = [
compId: "articles-docs-studio-quick-switcher",
crumb: "Remotion Studio",
},
+ {
+ id: "studio/save-default-props",
+ title: "saveDefaultProps()",
+ relativePath: "docs/studio/save-default-props.mdx",
+ compId: "articles-docs-studio-save-default-props",
+ crumb: "@remotion/studio",
+ },
{
id: "studio/shortcuts",
title: "Keyboard navigation",
@@ -2934,6 +2941,13 @@ export const articles = [
compId: "articles-docs-terminology-remotion-root",
crumb: "Terminology",
},
+ {
+ id: "terminology/root-file",
+ title: "Root file",
+ relativePath: "docs/terminology/root-file.mdx",
+ compId: "articles-docs-terminology-root-file",
+ crumb: "Terminology",
+ },
{
id: "terminology/sequence",
title: "Sequence",
diff --git a/packages/docs/static/generated/articles-docs-studio-save-default-props.png b/packages/docs/static/generated/articles-docs-studio-save-default-props.png
new file mode 100644
index 0000000000..12ddea9b06
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-studio-save-default-props.png differ
diff --git a/packages/docs/static/generated/articles-docs-terminology-root-file.png b/packages/docs/static/generated/articles-docs-terminology-root-file.png
new file mode 100644
index 0000000000..f28e38c814
Binary files /dev/null and b/packages/docs/static/generated/articles-docs-terminology-root-file.png differ
diff --git a/packages/studio/src/api/update-default-props.tsx b/packages/studio/src/api/save-default-props.tsx
similarity index 100%
rename from packages/studio/src/api/update-default-props.tsx
rename to packages/studio/src/api/save-default-props.tsx
diff --git a/packages/studio/src/index.ts b/packages/studio/src/index.ts
index 4ccab2dd19..4ba60227ab 100644
--- a/packages/studio/src/index.ts
+++ b/packages/studio/src/index.ts
@@ -1,3 +1,3 @@
export {StaticFile, getStaticFiles} from './api/get-static-files';
-export {saveDefaultProps} from './api/update-default-props';
+export {saveDefaultProps} from './api/save-default-props';
export {watchStaticFile} from './api/watch-static-file';