packages/victory-core/src/victory-util/axis.js
function getAxisComponentsWithParent(childComponents, type) {
  const matchesType = (child) => {
    return type === "dependent" ? child.props.dependentAxis : !child.props.dependentAxis;
  };

  const findComponents = (children) => {
    return children.reduce((memo, child) => {
      if (child.type && child.type.role === "axis" && matchesType(child)) {
        return memo.concat(child);
      } else if (child.props && child.props.children) {
        const childAxis = findComponents(React.Children.toArray(child.props.children));
        return childAxis.length > 0 ? memo.concat(child) : memo;
      }
      return memo;
    }, []);
  };

  return findComponents(childComponents);
}
function getAxisComponentsWithParent(childComponents, type) {
  const matchesType = (child) => {
    return type === "dependent" ? child.props.dependentAxis : !child.props.dependentAxis;
  };

  const findComponents = (children) => {
    return children.reduce((memo, child) => {
      if (child.type && child.type.role === "axis" && matchesType(child)) {
        return memo.concat(child);
      } else if (child.props && child.props.children) {
        const childAxis = findComponents(React.Children.toArray(child.props.children));
        return childAxis.length > 0 ? memo.concat(child) : memo;
      }
      return memo;
    }, []);
  };

  return findComponents(childComponents);
}
function getAxisComponentsWithParent ( childComponents , type ) { const matchesType = ( child ) => { return type === "dependent" ? child . props . dependentAxis : ! child . props . dependentAxis ; } ; const findComponents = ( children ) => { return children . reduce ( ( memo , child ) => { if ( child . type && child . type . role === "axis" && matchesType ( child ) ) { return memo . concat ( child ) ; } else if ( child . props && child . props . children ) { const childAxis = findComponents ( React . Children . toArray ( child . props . children ) ) ; return childAxis . length > 0 ? memo . concat ( child ) : memo ; } return memo ; } , [ ] ) ; } ; return findComponents ( childComponents ) ; }
Returns all axis components of the desired axis type (x or y) along with any
parent components excluding VictoryChart
@param {Array} childComponents: an optional array of children.
@param {String} type: desired axis either "dependent" or "independent".
@returns {ReactComponent} an axis component of the desired type or undefined
Returns all axis components of the desired axis type ( x or y ) along with any parent components excluding VictoryChart