src/components/type/type.js
/**
   * returns a list of subtype components for Array types.
   *
   * @return {ReactFragment}   array of <Type> components for subtype bar
   */
returns a list of subtype components for Array types.
@return {ReactFragment}   array of  components for subtype bar
returns a list of subtype components for Array types . @return { ReactFragment } array of components for subtype bar
_getArraySubTypes() {
    if (this.props.name !== 'Array') {
      return null;
    }
    if (!this.props.showSubTypes) {
      return null;
    }
    const subtypes = sortBy(this.props.types, (type) => {
      if (type.name === 'Undefined') {
        return -Infinity;
      }
      return type.probability;
    }).reverse();
    const activeSubType = find(subtypes, this.props.activeType);
    const typeList = subtypes.map((subtype) => {
      return (
        <Type
          key={'subtype-' + subtype.name}
          activeType={activeSubType}
          renderType={this.subTypeClicked.bind(this, subtype)}
          self={subtype}
          showSubTypes={false}
          {...subtype}
        />
      );
    });
    return (
      <div className="array-subtypes">
        <div className="schema-field-type-list">
          {typeList}
        </div>
      </div>
    );
  }
_getArraySubTypes ( ) { if ( this . props . name !== 'Array' ) { return null ; } if ( ! this . props . showSubTypes ) { return null ; } const subtypes = sortBy ( this . props . types , ( type ) => { if ( type . name === 'Undefined' ) { return - Infinity ; } return type . probability ; } ) . reverse ( ) ; const activeSubType = find ( subtypes , this . props . activeType ) ; const typeList = subtypes . map ( ( subtype ) => { return ( < Type key = { 'subtype-' + subtype . name } activeType = { activeSubType } renderType = { this . subTypeClicked . bind ( this , subtype ) } self = { subtype } showSubTypes = { false } { ... subtype } / > ) ; } ) ; return ( < div className = "array-subtypes" > < div className = "schema-field-type-list" > { typeList } < / div > < / div > ) ; }
returns a list of subtype components for Array types.
returns a list of subtype components for Array types .
// only worry about subtypes if the type is Array // only show one level of subtypes, further Arrays inside Arrays don't // render their subtypes. // sort the subtypes same as types (by probability, undefined last) // is one of the subtypes active? // generate the react fragment of subtypes, pass in showSubTypes=false // to stop the recursion after one step.