We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
import React, { Component, PropTypes } from 'react'; export default class MyPropsDemo extends Component { render() { const { collapsed = '', num = '', itemClassName = '', nodeLabel, children, ...rest, } = this.props; return(<div>{children}</div>); } } MyPropsDemo.propTypes = { collapsed: PropTypes.bool, nodeLabel: PropTypes.node.isRequired, num: PropTypes.number, itemClassName: PropTypes.string, onClick: PropTypes.func, children: PropTypes.oneOfType([ PropTypes.node, PropTypes.arrayOf(PropTypes.node) ]).isRequired, }; // Specifies the default values for props: MyPropsDemo.defaultProps = { collapsed: false };
optionalUnion: React.PropTypes.oneOfType([ React.PropTypes.string, React.PropTypes.number, PropTypes.arrayOf(PropTypes.node) ])
You can chain any of the above with isRequired to make sure a warning is shown if the prop isn't provided.
isRequired
1、facebook官网《Prop Validation》
The text was updated successfully, but these errors were encountered:
No branches or pull requests
实例
Prop Validation
You can chain any of the above with
isRequired
to make sure a warning is shown if the prop isn't provided.参考链接
1、facebook官网《Prop Validation》
The text was updated successfully, but these errors were encountered: