🎥 Make videos programmatically with React
updateDefaultProps is an alias for saveDefaultProps
Jonny Burger344056ab1489
diff --git a/packages/docs/docs/studio/save-default-props.mdx b/packages/docs/docs/studio/save-default-props.mdxindex 364d381146..576a05ff98 100644--- a/packages/docs/docs/studio/save-default-props.mdx+++ b/packages/docs/docs/studio/save-default-props.mdx@@ -6,8 +6,8 @@ crumb: "@remotion/studio"# 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).-If you just want to update the default props in the Props Editor (right sidebar in the Studio) without saving them to the root file, use [`updateDefaultProps()`](/docs/studio/update-default-props).+Saves the [`defaultProps`](/docs/composition) for a [composition](/docs/terminology/composition) back to the [root file](/docs/terminology/root-file).+[`updateDefaultProps()`](/docs/studio/update-default-props) is an alias for this function.## Examplesdiff --git a/packages/docs/docs/studio/update-default-props.mdx b/packages/docs/docs/studio/update-default-props.mdxindex 0db7d3781a..bd5a4bd08c 100644--- a/packages/docs/docs/studio/update-default-props.mdx+++ b/packages/docs/docs/studio/update-default-props.mdx@@ -6,9 +6,13 @@ crumb: "@remotion/studio"# updateDefaultProps()<AvailableFrom v="4.0.154"/>-Updates the default props in the Props Editor (in the right sidebar in the Studio).-Your component will be re-rendered with the new props.-The props will **not** be saved to the [Root file](/docs/terminology/root-file) - use [`saveDefaultProps()`](/docs/studio/save-default-props) for that.+Updates the [`defaultProps`](/docs/composition) for a [composition](/docs/terminology/composition) and saves them back to the [root file](/docs/terminology/root-file).++This function is an alias for [`saveDefaultProps()`](/docs/studio/save-default-props).++:::info+Before v4.0.437, this function only updated the props in the Props Editor without saving them to the root file. Starting from v4.0.437, it also saves the props to the root file.+:::## Examples@@ -16,7 +20,7 @@ The props will **not** be saved to the [Root file](/docs/terminology/root-file)// @target: esnextimport { updateDefaultProps } from "@remotion/studio";-updateDefaultProps({+await updateDefaultProps({compositionId: "my-composition",defaultProps: () => {return {@@ -30,9 +34,9 @@ You can access the current unsaved default props to only override part of it (re```tsx twoslash title="Accessing the current props"// @target: esnext-import { saveDefaultProps } from "@remotion/studio";+import { updateDefaultProps } from "@remotion/studio";-await saveDefaultProps({+await updateDefaultProps({compositionId: "my-composition",defaultProps: ({ unsavedDefaultProps }) => {return { ...unsavedDefaultProps, color: "green" };@@ -46,7 +50,7 @@ If you only want to override on top of the saved changes:// @target: esnextimport { updateDefaultProps } from "@remotion/studio";-updateDefaultProps({+await updateDefaultProps({compositionId: "my-composition",defaultProps: ({ savedDefaultProps }) => {return {@@ -63,7 +67,7 @@ If you have a Zod schema, you can also access its runtime value:// @target: esnextimport { updateDefaultProps } from "@remotion/studio";-updateDefaultProps({+await updateDefaultProps({compositionId: "my-composition",defaultProps: ({ schema, unsavedDefaultProps }) => {// Do something with the Zod schema@@ -92,4 +96,5 @@ Otherwise, the function will throw.## See also+- [`saveDefaultProps()`](/docs/studio/save-default-props)- [Source code for this function](https://github.com/remotion-dev/remotion/blob/main/packages/studio/src/api/update-default-props.ts)diff --git a/packages/studio/src/api/update-default-props.ts b/packages/studio/src/api/update-default-props.tsindex 8296d36fe1..b1b0dca1a5 100644--- a/packages/studio/src/api/update-default-props.ts+++ b/packages/studio/src/api/update-default-props.ts@@ -1,31 +1,7 @@-import {Internals} from 'remotion';-import type {UpdateDefaultPropsFunction} from './helpers/calc-new-props';-import {calcNewProps} from './helpers/calc-new-props';+import {saveDefaultProps} from './save-default-props';-// TODO: Saving is now instant-export const updateDefaultProps = ({- compositionId,- defaultProps,-}: {- compositionId: string;- defaultProps: UpdateDefaultPropsFunction;-}) => {- const {generatedDefaultProps, composition} = calcNewProps(- compositionId,- defaultProps,- );-- const propsStore = Internals.editorPropsProviderRef.current;- if (!propsStore) {- throw new Error(- 'No props store found. Are you in the Remotion Studio and are the Remotion versions aligned?',- );- }-- propsStore.setProps((prev) => {- return {- ...prev,- [composition.id]: generatedDefaultProps,- };- });-};+/*+ * @description Updates and saves the defaultProps for a composition back to the root file. Alias for saveDefaultProps().+ * @see [Documentation](https://www.remotion.dev/docs/studio/update-default-props)+ */+export const updateDefaultProps = saveDefaultProps;