prop-types-falsy
v0.1.0
Published
falsy values as prop types
Downloads
7
Readme
prop-types-falsy
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