Skip to content

Latest commit

 

History

History
47 lines (35 loc) · 767 Bytes

README.md

File metadata and controls

47 lines (35 loc) · 767 Bytes

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