How to use the airbnb-prop-types.or 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
AirbnbPropTypes.nonNegativeInteger;

// $ExpectType Requireable
AirbnbPropTypes.nonNegativeNumber();

// $ExpectType Requireable
AirbnbPropTypes.numericString();

// $ExpectType Requireable
const props: PropTypes.Requireable = AirbnbPropTypes.object();
// $ExpectType Requireable<{ foo: string; }>
AirbnbPropTypes.object<{ foo: string }>();

AirbnbPropTypes.or([PropTypes.bool.isRequired, AirbnbPropTypes.explicitNull().isRequired]);
AirbnbPropTypes.or([PropTypes.bool, PropTypes.number, PropTypes.arrayOf(PropTypes.string)]);
AirbnbPropTypes.or([PropTypes.number, PropTypes.string, PropTypes.bool], 'foo');

// $ExpectType Requireable
AirbnbPropTypes.range(0, 10);
// $ExpectType Requireable<5>
AirbnbPropTypes.range<5>(0, 10);

// $ExpectType Requireable>
AirbnbPropTypes.ref();

// $ExpectType Requireable
AirbnbPropTypes.requiredBy('foo', PropTypes.string);
// $ExpectType Validator
AirbnbPropTypes.requiredBy('bar', PropTypes.number, 42).isRequired;

validateRequireableTop(AirbnbPropTypes.restrictedProp());
validateRequireableTop(AirbnbPropTypes.restrictedProp(() => 'Error'));
github danielrob / aperitif-editor / src / containers / FileExplorerContainer / containers / FileContainer.js View on Github external
innerRef={innerRef => connectDragSource(findDOMNode(innerRef))}
        onClick={this.onClickHandler}
        {...props}
      />
    )
  }
}


/*
  propTypes
*/
FileContainer.propTypes = forbidExtraProps({
  // passed by parent / file explorer
  fileId: T.number.isRequired,
  parentName: or([T.string.isRequired, explicitNull()]), // eslint-disable-line
  path: T.arrayOf(T.number),

  // from makeSelectFile
  file: T.shape(filePropTypes).isRequired,

  // mapDispatchToProps
  changeFile: T.func.isRequired,
  moveDeclarationToFile: T.func.isRequired,
  moveFile: T.func.isRequired,

  // injected by React DnD
  connectDragSource: T.func.isRequired,
  connectDragPreview: T.func.isRequired,
  connectDropTarget: T.func.isRequired,
  isDragging: T.bool.isRequired,
})
github danielrob / aperitif-editor / src / containers / FileExplorerContainer / components / File.js View on Github external
))}
      
    )
  }
}

File.propTypes = forbidExtraProps({
  // passed by parent / file explorer
  // eslint-disable-next-line react/require-default-props
  parentName: or([T.string.isRequired, explicitNull()]),
  path: T.arrayOf(T.number).isRequired,

  file: T.shape(filePropTypes).isRequired,
  // Injected by React DnD:
  connectDragPreview: T.func.isRequired,
  connectDropTarget: T.func.isRequired,
  isDragging: T.bool.isRequired,

  // for wrapper
  innerRef: T.func.isRequired,
  onClick: T.func.isRequired,
})

const NoWrap = styled.div`
  white-space: nowrap;
`
github airbnb / react-dates / src / components / CustomizableCalendarDay.jsx View on Github external
const { hover } = stylesObj;
  if (isHovered && hover) {
    return hover;
  }

  return stylesObj;
}

const DayStyleShape = PropTypes.shape({
  background: PropTypes.string,
  border: or([PropTypes.string, PropTypes.number]),
  color: PropTypes.string,

  hover: PropTypes.shape({
    background: PropTypes.string,
    border: or([PropTypes.string, PropTypes.number]),
    color: PropTypes.string,
  }),
});

const propTypes = forbidExtraProps({
  ...withStylesPropTypes,
  day: momentPropTypes.momentObj,
  daySize: nonNegativeInteger,
  isOutsideDay: PropTypes.bool,
  modifiers: PropTypes.instanceOf(Set),
  isFocused: PropTypes.bool,
  tabIndex: PropTypes.oneOf([0, -1]),
  onDayClick: PropTypes.func,
  onDayMouseEnter: PropTypes.func,
  onDayMouseLeave: PropTypes.func,
  renderDayContents: PropTypes.func,
github airbnb / react-sketchapp / src / components / Page.tsx View on Github external
import * as React from 'react';
import * as PropTypes from 'prop-types';
import { or } from 'airbnb-prop-types';
import StyleSheet from '../stylesheet';
import PageStylePropTypes from './PageStylePropTypes';

export const PagePropTypes = {
  name: PropTypes.string,
  children: PropTypes.node,
  style: or([PropTypes.shape(PageStylePropTypes), PropTypes.number]),
};

type Props = PropTypes.InferProps;

export default class Page extends React.Component {
  static propTypes = PagePropTypes;

  render() {
    const { name, children, style, ...otherProps } = this.props;
    const _name = name === 'Symbols' ? 'Symbols (renamed to avoid conflict)' : name;
    const _style = StyleSheet.flatten(style);

    return (
      
        {children}