{"record":{"id":"912a04e24406100d","repo":"remotion-dev/remotion","slug":"could-not-locate-the-jsx-element-to-move","errorCode":null,"errorMessage":"Could not locate the JSX element to move","messagePattern":"Could not locate the JSX element to move","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/studio-codemods/src/folder-source-edits.ts","lineNumber":379,"sourceCode":"\t\t{type: 'move-composition-or-folder' | 'move-composition-to-folder'}\n\t>;\n\tinput: string;\n\titems: LocatedItem[];\n}): SourceEdit[] => {\n\tconst source =\n\t\tcodeMod.type === 'move-composition-to-folder'\n\t\t\t? (items.find(\n\t\t\t\t\t(item) =>\n\t\t\t\t\t\titem.directJsxChild &&\n\t\t\t\t\t\tgetCompositionIdFromJSXElement(item.node) === codeMod.idToMove,\n\t\t\t\t) ?? null)\n\t\t\t: (items.find(\n\t\t\t\t\t(item) =>\n\t\t\t\t\t\titem.directJsxChild &&\n\t\t\t\t\t\tmatchesItem({item: codeMod.source, located: item}),\n\t\t\t\t) ?? null);\n\tif (source === null) {\n\t\tthrow new Error('Could not locate the JSX element to move');\n\t}\n\n\tconst insertion = getJsxElementSourceForInsertion({\n\t\telement: source.node,\n\t\tinput,\n\t});\n\tlet insertionEdit: SourceEdit;\n\tif (codeMod.type === 'move-composition-to-folder') {\n\t\tif (codeMod.folderName === null) {\n\t\t\tconst root = getRegistrationRoot(source.path);\n\t\t\tinsertionEdit = getInsertionRootSourceEdit({\n\t\t\t\tinput,\n\t\t\t\tinsertion,\n\t\t\t\troot: root as never,\n\t\t\t\tnullRoot: null,\n\t\t\t\tprettierConfigOverride: null,\n\t\t\t\tinsertInside: root.type === 'JSXFragment',\n\t\t\t});","sourceCodeStart":361,"sourceCodeEnd":397,"githubUrl":"https://github.com/remotion-dev/remotion/blob/46a3a6bf13ca367376ff18bbb06dae2e87e0d068/packages/studio-codemods/src/folder-source-edits.ts#L361-L397","documentation":"Thrown by getMoveSourceEdits (folder-source-edits.ts:379) when no located, directly-JSX-child item matches the element the codemod wants to move: for `move-composition-to-folder`, no direct JSX child has the given composition id; for `move-composition-or-folder`, no direct child matches the source composition/folder descriptor.","triggerScenarios":"Moving a composition whose `<Composition id=...>` is not a direct child of a JSXElement/JSXFragment in the Root file, moving a folder whose name/parentName pair does not exist, or the id/parentName in the codemod being stale after the file was edited externally.","commonSituations":"The composition is rendered via a variable, map, or helper component instead of being a literal JSX child; out-of-date Studio state after manual edits to the Root file; typo'd or renamed composition id.","solutions":["Ensure the <Composition> or <Folder> is written as a direct JSX child inside the returned <Root> tree","Verify the composition id matches the id in the file (check for renames)","Reload Studio so it re-parses the current file contents, then retry the move","Move the element manually by cut/paste in the editor"],"exampleFix":"// before\n{comps.map((c) => <Composition key={c.id} id={c.id} ... />)}\n\n// after (literal child the codemod can locate)\n<Composition id=\"MyComp\" component={MyComp} durationInFrames={90} fps={30} width={1920} height={1080} />","handlingStrategy":"validation","validationCode":"const items = getLocatedItemsFromSource(input);\nconst movable = items.find((i) => i.directJsxChild && getCompositionIdFromJSXElement(i.node) === idToMove);\nif (!movable) throw new Error(`Composition ${idToMove} is not a direct JSX child; move it manually`);","typeGuard":null,"tryCatchPattern":"try {\n  editFolderInSource({codeMod, input});\n} catch (e) {\n  if (e instanceof Error && e.message === 'Could not locate the JSX element to move') {\n    // fall back to manual cut/paste in the editor\n  }\n}","preventionTips":["Write <Composition> elements as literal direct JSX children","Re-sync Studio state after renaming composition ids","Don't render compositions via .map() or helper components if you use Studio drag & drop"],"tags":["ast","codemod","move","composition"],"backgroundTag":"record-not-found","analyzedSha":"46a3a6bf13ca367376ff18bbb06dae2e87e0d068","analyzedAt":"2026-09-18T00:12:20.256Z","contentChangedAt":"2026-09-18T00:12:20.256Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}