8000 GitHub - ardalanamini/element-prop-types: React Element Prop Types · GitHub
[go: up one dir, main page]

Skip to content

About

React Element Prop Types

Resources

Code of conduct

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

10 Commits

Folders and files

Repository files navigation

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

About

React Element Prop Types

Resources

Code of conduct

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages

0