function _getParentComponent(node) {
    let currNode = node;
    while (currNode) {
      // Handle ES6 class syntax
      if (currNode.type === "ClassDeclaration") {
        return currNode;
      }
      // Handle React.createClass syntax
      if (currNode.type === "CallExpression" && currNode.callee) {
        const expression = currNode.callee;
        if (
          expression.object.name === "React" &&
          expression.property.name === "createClass"
        ) {
          return currNode.parent;
        }
      }
      currNode = currNode.parent;
    }
  }
/**
   * Traverse up the tree to find the parent component
   */
Traverse up the tree to find the parent component
Traverse up the tree to find the parent component
function _getParentComponent(node) {
    let currNode = node;
    while (currNode) {
      if (currNode.type === "ClassDeclaration") {
        return currNode;
      }
      if (currNode.type === "CallExpression" && currNode.callee) {
        const expression = currNode.callee;
        if (
          expression.object.name === "React" &&
          expression.property.name === "createClass"
        ) {
          return currNode.parent;
        }
      }
      currNode = currNode.parent;
    }
  }
function _getParentComponent ( node ) { let currNode = node ; while ( currNode ) { if ( currNode . type === "ClassDeclaration" ) { return currNode ; } if ( currNode . type === "CallExpression" && currNode . callee ) { const expression = currNode . callee ; if ( expression . object . name === "React" && expression . property . name === "createClass" ) { return currNode . parent ; } } currNode = currNode . parent ; } }
Traverse up the tree to find the parent component
Traverse up the tree to find the parent component
// Handle ES6 class syntax // Handle React.createClass syntax