Skip to content

chentsulin/prop-types-falsy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

falsy values as prop types

Resources

License

Stars

Watchers

Forks

Packages

No packages published