element-prop-types
Version:
React PropType for props-elements
50 lines (38 loc) • 1.13 kB
Markdown
# element-prop-types
React PropTypes for props-elements
[](https://www.npmjs.com/package/element-prop-types)
[](https://www.npmjs.com/package/element-prop-types)
[](https://github.com/ardalanamini/element-prop-types/blob/master/LICENSE)
## Install
```
npm install --save element-prop-types
```
## Usage
```js
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