Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

element-prop-types

ardalanamini48MIT1.0.3TypeScript support: included

React PropType for props-elements

react, prop, prop-type, proptype, element

readme

element-prop-types

React PropTypes for props-elements

npm npm GitHub license

Install

npm install --save element-prop-types

Usage

const ElementPropTypes = require('element-prop-types');

const Modal = ({ header, items }) => (
    <div>
        <div>{header}</div>
        <div>{items}</div>
    </div>
);

Modal.propTypes = {
    header: ElementPropTypes.elementOf(Header).isRequired,
    items: PropTypes.arrayOf(ElementPropTypes.elementOf(Item))
};

// render Modal
React.render(
    <Modal
       header={<Header title="This is modal" />}
       items={[
           <Item/>,
           <Item/>,
           <Item/>
       ]}
    />,
    rootElement
);

API

elementOf(Component)

checks the type of a React element