Skip to content
New issue

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

Document PropTypes.renderable and PropTypes.component #862

Merged
merged 1 commit into from
Jan 10, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 27 additions & 0 deletions docs/docs/05-reusable-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -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']),
Expand Down Expand Up @@ -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

Expand Down