How to use the airbnb-prop-types.childrenOfType function in airbnb-prop-types

To help you get started, we’ve selected a few airbnb-prop-types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / airbnb-prop-types / airbnb-prop-types-tests.ts View on Github external
// $ExpectType Requireable
AirbnbPropTypes.between({ gte: 4 });
// $ExpectType Requireable
AirbnbPropTypes.between({ lt: 1, gt: 0 });

// $ExpectType Requireable
AirbnbPropTypes.booleanSome('foo', 'bar', 'baz');

// $ExpectType Requireable
AirbnbPropTypes.childrenHavePropXorChildren('foo');

// $ExpectType Requireable
AirbnbPropTypes.childrenOf(PropTypes.string);

// $ExpectType Requireable
AirbnbPropTypes.childrenOfType(ClassComp);
// $ExpectType Requireable
AirbnbPropTypes.childrenOfType(FuncComp);
// $ExpectType Requireable
AirbnbPropTypes.childrenOfType('div');
// $ExpectType Requireable
AirbnbPropTypes.childrenOfType(ClassComp, FuncComp, 'div');

// $ExpectType Requireable
AirbnbPropTypes.childrenSequenceOf({ validator: PropTypes.number });
// $ExpectType Requireable
AirbnbPropTypes.childrenSequenceOf({ validator: PropTypes.string, max: 100 });
// $ExpectType Requireable
AirbnbPropTypes.childrenSequenceOf({ validator: PropTypes.bool, min: 0 });

// $ExpectType Requireable
AirbnbPropTypes.componentWithName('Foo');
github DefinitelyTyped / DefinitelyTyped / types / airbnb-prop-types / airbnb-prop-types-tests.ts View on Github external
// $ExpectType Requireable
AirbnbPropTypes.between({ lt: 1, gt: 0 });

// $ExpectType Requireable
AirbnbPropTypes.booleanSome('foo', 'bar', 'baz');

// $ExpectType Requireable
AirbnbPropTypes.childrenHavePropXorChildren('foo');

// $ExpectType Requireable
AirbnbPropTypes.childrenOf(PropTypes.string);

// $ExpectType Requireable
AirbnbPropTypes.childrenOfType(ClassComp);
// $ExpectType Requireable
AirbnbPropTypes.childrenOfType(FuncComp);
// $ExpectType Requireable
AirbnbPropTypes.childrenOfType('div');
// $ExpectType Requireable
AirbnbPropTypes.childrenOfType(ClassComp, FuncComp, 'div');

// $ExpectType Requireable
AirbnbPropTypes.childrenSequenceOf({ validator: PropTypes.number });
// $ExpectType Requireable
AirbnbPropTypes.childrenSequenceOf({ validator: PropTypes.string, max: 100 });
// $ExpectType Requireable
AirbnbPropTypes.childrenSequenceOf({ validator: PropTypes.bool, min: 0 });

// $ExpectType Requireable
AirbnbPropTypes.componentWithName('Foo');
// $ExpectType Requireable
AirbnbPropTypes.componentWithName(/Foo/);
github DefinitelyTyped / DefinitelyTyped / types / airbnb-prop-types / airbnb-prop-types-tests.ts View on Github external
// $ExpectType Requireable
AirbnbPropTypes.booleanSome('foo', 'bar', 'baz');

// $ExpectType Requireable
AirbnbPropTypes.childrenHavePropXorChildren('foo');

// $ExpectType Requireable
AirbnbPropTypes.childrenOf(PropTypes.string);

// $ExpectType Requireable
AirbnbPropTypes.childrenOfType(ClassComp);
// $ExpectType Requireable
AirbnbPropTypes.childrenOfType(FuncComp);
// $ExpectType Requireable
AirbnbPropTypes.childrenOfType('div');
// $ExpectType Requireable
AirbnbPropTypes.childrenOfType(ClassComp, FuncComp, 'div');

// $ExpectType Requireable
AirbnbPropTypes.childrenSequenceOf({ validator: PropTypes.number });
// $ExpectType Requireable
AirbnbPropTypes.childrenSequenceOf({ validator: PropTypes.string, max: 100 });
// $ExpectType Requireable
AirbnbPropTypes.childrenSequenceOf({ validator: PropTypes.bool, min: 0 });

// $ExpectType Requireable
AirbnbPropTypes.componentWithName('Foo');
// $ExpectType Requireable
AirbnbPropTypes.componentWithName(/Foo/);
// $ExpectType Requireable
AirbnbPropTypes.componentWithName('Foo', { stripHOCs: ['connect'] });
github titon / toolkit / src / components / Accordion / Accordion.js View on Github external
import style, { classes } from '../../styler';
import { classNamesPropType, numberCollectionPropType } from '../../propTypes';
import contextTypes from './contextTypes';

import type { AccordionContext, AccordionProps, AccordionState } from './types';

export class ToolkitAccordion extends React.Component {
  context: AccordionContext;
  props: AccordionProps;

  static childContextTypes = {
    accordion: contextTypes.isRequired,
  };

  static propTypes = {
    children: childrenOfType(Item).isRequired,
    classNames: classNamesPropType.isRequired,
    collapsible: PropTypes.bool,
    defaultIndex: numberCollectionPropType,
    multiple: PropTypes.bool,
  };

  static defaultProps = {
    collapsible: false,
    defaultIndex: 0,
    multiple: false,
  };

  state: AccordionState = {
    indices: new Set(),
  };
github airbnb / lunar / packages / core / src / components / Select / index.tsx View on Github external
export type Props = Omit &
  FormFieldProps & {
    /** Dropdown options. Supports `option` and `optgroup`. */
    children: NonNullable;
    /** Empty and disabled option to display the top of the list. */
    placeholder?: string;
  };

export type State = {
  id: string;
};

/** A controlled select field. */
export default class Select extends React.Component {
  static propTypes = {
    children: childrenOfType('option', 'optgroup').isRequired,
  };

  static defaultProps = {
    placeholder: '',
  };

  state = {
    id: uuid(),
  };

  render() {
    const { children, fieldProps, inputProps } = partitionFieldProps(this.props);
    const { id } = this.state;

    return (
github airbnb / lunar / packages / core / src / components / SteppedProgressBar / index.tsx View on Github external
const steps = React.Children.count(children);

  return (
    <div>
      {React.Children.map(children, (child, index) =&gt;
        React.cloneElement(child as React.ReactElement, {
          first: index === 0,
          last: index === steps - 1,
        }),
      )}
    </div>
  );
}

SteppedProgressBar.propTypes = {
  children: childrenOfType(Step).isRequired,
};

export { Step };

export default SteppedProgressBar;
github airbnb / lunar / packages / core / src / components / Grid / index.tsx View on Github external
)}
    &gt;
      {children}
    
  );
}

export { Col };

const horizontalAlignProp = mutuallyExclusiveTrueProps('centerAlign', 'startAlign', 'endAlign');
const verticalAlignProp = mutuallyExclusiveTrueProps('bottomAlign', 'middleAlign', 'topAlign');

Grid.propTypes = {
  bottomAlign: verticalAlignProp,
  centerAlign: horizontalAlignProp,
  children: childrenOfType(Col).isRequired,
  endAlign: horizontalAlignProp,
  middleAlign: verticalAlignProp,
  startAlign: horizontalAlignProp,
  topAlign: verticalAlignProp,
};

export default Grid;
github goodjoblife / GoodJobShare / src / components / common / Carousel.js View on Github external
/&gt;
        ))}
        <button disabled="{!isNextBtnClickable}">
          &gt;
        </button>
      
    
  );
};

Carousel.propTypes = {
  children: childrenOfType(CarouselPage).isRequired,
  selectedIndex: PropTypes.number.isRequired,
  onSelectIndex: PropTypes.func.isRequired,
};

export default Carousel;
github telus / tds-core / src / components / Textarea / Textarea.jsx View on Github external
error: PropTypes.string,
  /**
   * A detailed explanation of the input expected by a form field. Can be text,
   * other components, or HTML elements.
   *
   * If a function is provided, it must return an `InputFeedback`. The function will be
   * invoked with the following arguments.
   *
   * @param {String} feedback The input's current feedback state.
   * @param {String} value The input's current value.
   */
  helper: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
  /**
   * A `Tooltip`
   */
  tooltip: childrenOfType(Tooltip),
  /**
   * A callback function to be invoked when the input value changes.
   *
   * @param {SyntheticEvent} event The React `SyntheticEvent`
   */
  onChange: PropTypes.func,
  /**
   * A callback function to be invoked when the input receives focus.
   *
   * @param {SyntheticEvent} event The React `SyntheticEvent`
   */
  onFocus: PropTypes.func,
  /**
   * A callback function to be invoked when the input loses focus.
   *
   * @param {SyntheticEvent} event The React `SyntheticEvent`