MCPcopy Create free account
hub / github.com/donghaxkim/react-rewrite / getMovableNode

Function getMovableNode

packages/cli/src/transform.ts:69–79  ·  view source on GitHub ↗
(nodePath: any)

Source from the content-addressed store, hash-verified

67 if (!toNode) throw new Error(`Component not found at line ${toLine}. If you have unsaved changes in your editor, save your files and try again.`);
68
69 function getMovableNode(nodePath: any): any {
70 let current = nodePath;
71 while (current.parent) {
72 const parentNode = current.parent.node;
73 if (parentNode.children && parentNode.children.indexOf(current.node) !== -1) {
74 return current;
75 }
76 current = current.parent;
77 }
78 return nodePath;
79 }
80
81 const fromMovable = getMovableNode(fromNode);
82 const toMovable = getMovableNode(toNode);

Callers 1

mutateReorderFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected