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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    2,850
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    2,850

Package Sidebar

Install

npm i react-element-proptypes

Weekly Downloads

2,850

Version

1.0.0

License

Apache-2.0

Last publish

Collaborators

  • wizardzloy