{"record":{"id":"383d27be40312e1b","repo":"remotion-dev/remotion","slug":"could-not-locate-the-jsx-reorder-target","errorCode":null,"errorMessage":"Could not locate the JSX reorder target","messagePattern":"Could not locate the JSX reorder target","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/studio-codemods/src/folder-source-edits.ts","lineNumber":454,"sourceCode":"\n\t\tinsertionEdit = getInsertionRootSourceEdit({\n\t\t\tinput,\n\t\t\tinsertion,\n\t\t\troot: destination.node as never,\n\t\t\tnullRoot: null,\n\t\t\tprettierConfigOverride: null,\n\t\t\tinsertInside: true,\n\t\t});\n\t} else {\n\t\tconst {destination} = codeMod;\n\t\tconst target =\n\t\t\titems.find(\n\t\t\t\t(item) =>\n\t\t\t\t\titem.directJsxChild &&\n\t\t\t\t\tmatchesItem({item: destination.target, located: item}),\n\t\t\t) ?? null;\n\t\tif (target === null) {\n\t\t\tthrow new Error('Could not locate the JSX reorder target');\n\t\t}\n\n\t\tinsertionEdit = getAdjacentJsxInsertionSourceEdit({\n\t\t\tinput,\n\t\t\tinsertion,\n\t\t\tposition: destination.type,\n\t\t\ttarget: target.node,\n\t\t});\n\t}\n\n\treturn [getNodeSourceEdit({input, jsxPath: source.path}), insertionEdit];\n};\n\nexport const editFolderInSource = ({\n\tcodeMod,\n\tinput,\n}: {\n\tcodeMod: FolderCodemod;","sourceCodeStart":436,"sourceCodeEnd":472,"githubUrl":"https://github.com/remotion-dev/remotion/blob/46a3a6bf13ca367376ff18bbb06dae2e87e0d068/packages/studio-codemods/src/folder-source-edits.ts#L436-L472","documentation":"Thrown by getMoveSourceEdits (folder-source-edits.ts:454) when a move's destination is a positional reorder (before/after a sibling) but no direct JSX child matches destination.target. The codemod needs the neighbor element's node to compute an adjacent insertion edit; without it the reorder cannot be placed.","triggerScenarios":"A move-composition-or-folder codemod with destination type 'before'/'after' whose target descriptor (composition id or folder name+parent) matches no direct JSX child in the parsed file — the target sibling was removed, renamed, moved, or is not a literal JSX child.","commonSituations":"Reordering in the Studio timeline while another client/editor concurrently modified the Root file; the target item is rendered via a variable or helper so it is not a directJsxChild; stale Studio state after renaming the target composition.","solutions":["Confirm the target sibling composition/folder exists as a literal direct JSX child with the expected id/name","Reload the Studio so it re-reads the Root file and retry the reorder","Reorder the elements manually by moving JSX lines in the editor"],"exampleFix":"// before (target rendered dynamically, not locatable)\n{renderComp('TargetComp')}\n\n// after (literal sibling the codemod can anchor to)\n<Composition id=\"TargetComp\" component={TargetComp} ... />","handlingStrategy":"validation","validationCode":"const target = locateDirectChild(input, codeMod.destination.target);\nif (!target) throw new Error('Reorder target sibling not found as a literal JSX child');","typeGuard":null,"tryCatchPattern":"try {\n  editFolderInSource({codeMod, input});\n} catch (e) {\n  if (e instanceof Error && e.message === 'Could not locate the JSX reorder target') {\n    // fall back to manual reordering of JSX lines\n  }\n}","preventionTips":["Keep the reorder target as a literal direct JSX child","Avoid concurrent edits while reordering in Studio","Reload Studio after manual changes to the Root file"],"tags":["ast","codemod","reorder","jsx"],"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"}