react-element-proptypes

1.0.0 • Public • Published

react-element-proptypes

React PropTypes for props-elements

Install

npm install --save react-element-proptypes

Usage

const ElementPropTypes = require('react-element-proptypes');
 
const Modal = ({ header, items }) => (
    <div>
        <div>{header}</div>
        <div>{items}</div>
    </div>
);
 
Modal.propTypes = {
    header: ElementPropTypes.elementOfType(Header).isRequired,
    items: React.PropTypes.arrayOf(ElementPropTypes.elementOfType(Item))
};
 
// render Modal
React.render(
    <Modal
       header={<Header title="This is modal" />}
       items={[
           <Item/>,
           <Item/>,
           <Item/>
       ]}
    />,
    rootElement
);

API

elementOfType(Component)

checks the type of a React element

Dependents (5)

Package Sidebar

Install

npm i react-element-proptypes

Weekly Downloads

2,334

Version

1.0.0

License

Apache-2.0

Last publish

Collaborators

  • wizardzloy