mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 12:20:20 +01:00
Document PropTypes.renderable and PropTypes.component
This commit is contained in:
parent
338ce603f9
commit
d73f80ecb2
|
|
@ -26,6 +26,13 @@ React.createClass({
|
|||
optionalObject: React.PropTypes.object,
|
||||
optionalString: React.PropTypes.string,
|
||||
|
||||
// Anything that can be rendered: numbers, strings, components or an array
|
||||
// containing these types.
|
||||
optionalRenderable: React.PropTypes.renderable,
|
||||
|
||||
// A React component.
|
||||
optionalComponent: React.PropTypes.component,
|
||||
|
||||
// You can ensure that your prop is limited to specific values by treating
|
||||
// it as an enum.
|
||||
optionalEnum: React.PropTypes.oneOf(['News','Photos']),
|
||||
|
|
@ -91,6 +98,26 @@ React.renderComponent(
|
|||
);
|
||||
```
|
||||
|
||||
## Single Child
|
||||
|
||||
With `React.PropTypes.component` you can specify that only a single child can be passed to
|
||||
a component as children.
|
||||
|
||||
```javascript
|
||||
var MyComponent = React.createClass({
|
||||
propTypes: {
|
||||
children: React.PropTypes.component.isRequired
|
||||
},
|
||||
|
||||
render: function() {
|
||||
return
|
||||
<div>
|
||||
{this.props.children} // This must be exactly one element or it will throw.
|
||||
</div>;
|
||||
}
|
||||
|
||||
});
|
||||
```
|
||||
|
||||
## Mixins
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user