setCompositionDefaultProps()v4.0.528
Replaces a composition's statically readable default props or adds them when missing.
Draft API: This API is experimental and may change.
set-composition-default-props.tsimport {setCompositionDefaultProps , typeCodemodProject } from '@remotion/codemods'; declare constproject :CodemodProject ; constresult =setCompositionDefaultProps ({project ,compositionFile : 'src/Root.tsx',compositionId : 'MyComposition',defaultProps : {title : 'Hello',backgroundColor : '#ffffff'}, });console .log (result );
Computed default props and props potentially overridden by a spread are rejected. The component implementation is unchanged.
Options
project
An in-memory CodemodProject. The input project is not mutated.
compositionFile
The project file containing the composition registrations. Registration edits support <Composition>, <Still>, and <Folder> with their original import names and static IDs or folder names.
compositionId
The static ID of the composition to edit.
defaultProps
The complete replacement object of serializable prop values. This replaces the object rather than merging it.
Return value
Returns an object with the following properties.
project
The updated project. Unchanged files and extra project fields are preserved.
changes
An array of {filePath, previousContents, nextContents} file changes. A null content value indicates a created or deleted file.
nodePathRemappings
An array of {filePath, oldNodePath, newNodePath} mappings. A null old path indicates an insertion; a null new path indicates removal. Apply these mappings to references from the input project. See node references.
updatedNode
The composition registration's node reference.
Errors
Throws when the target cannot be resolved, the requested edit is unsupported, or an option is invalid. Failed edits leave the input project unchanged.
Compatibility
| Browsers | Servers | Environments | |||||||
|---|---|---|---|---|---|---|---|---|---|
Chrome | Firefox | Safari | Node.js | Bun | Serverless Functions | ||||