0.1.0 • Published 6 years ago

prop-types-falsy v0.1.0

Weekly downloads
9
License
MIT
Repository
-
Last release
6 years ago

prop-types-falsy

npm

Installation

npm install prop-types-falsy

Usage

const falsy = require('prop-types-falsy');

MyComponent.propTypes = {
  items: PropTypes.arrayOf([
    PropTypes.oneOfType([
      PropTypes.shape({
        x: PropTypes.string.isRequired,
        y: PropTypes.number.isRequired,
      }),
      falsy,
    ]),
  ]).isRequired,
};

<MyComponent
  items={[
    {
      x: 'hello',
      y: 10,
    },
    isXxxx && {
      x: 'cool',
      y: 100,
    },
    myItems.length && {
      x: 'wow',
      y: 1000,
    },
  ]}
/>;

License

MIT © C.T.Lin