Back to Remotion

updateDefaultProps()

packages/docs/docs/studio/update-default-props.mdx

4.0.4772.4 KB
Original Source

updateDefaultProps()<AvailableFrom v="4.0.154"/>

:::info Deprecated: This function is an alias for saveDefaultProps(). Use saveDefaultProps() instead.

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, all prop changes are immediately saved, making this function identical to saveDefaultProps(). :::

Examples

tsx
// @target: esnext
import { saveDefaultProps } from "@remotion/studio";

await saveDefaultProps({
  compositionId: "my-composition",
  defaultProps: () => {
    return {
      color: "green",
    };
  },
});

You can access the current default props to only override part of it (reducer-style):

tsx
// @target: esnext
import { saveDefaultProps } from "@remotion/studio";

await saveDefaultProps({
  compositionId: "my-composition",
  defaultProps: ({ savedDefaultProps }) => {
    return { ...savedDefaultProps, color: "green" };
  },
});

If you have a Zod schema, you can also access its runtime value:

tsx
// @target: esnext
import { saveDefaultProps } from "@remotion/studio";

await saveDefaultProps({
  compositionId: "my-composition",
  defaultProps: ({ schema, savedDefaultProps }) => {
    // Do something with the Zod schema

    return {
      ...savedDefaultProps,
      color: "red",
    };
  },
});

unsavedDefaultProps

:::info Before v4.0.437, unsavedDefaultProps contained props that were modified in the Props Editor but not yet written back to the root file. Starting from v4.0.437, all prop changes are immediately saved, so unsavedDefaultProps is now always the same as savedDefaultProps.

It is still accepted for backwards compatibility, but you should use savedDefaultProps instead. :::

Requirements

In order to use this function:

<Step>1</Step> You need to be inside the Remotion Studio.

<Step>2</Step> The Studio must be running (no static deployment)

<Step>3</Step> <code>zod</code> needs to be installed.

Otherwise, the function will throw.

See also