File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,13 @@ React.createClass({
26
26
optionalObject: React .PropTypes .object ,
27
27
optionalString: React .PropTypes .string ,
28
28
29
+ // Anything that can be rendered: numbers, strings, components or an array
30
+ // containing these types.
31
+ optionalRenderable: React .PropTypes .renderable ,
32
+
33
+ // A React component.
34
+ optionalComponent: React .PropTypes .component ,
35
+
29
36
// You can ensure that your prop is limited to specific values by treating
30
37
// it as an enum.
31
38
optionalEnum: React .PropTypes .oneOf ([' News' ,' Photos' ]),
@@ -91,6 +98,26 @@ React.renderComponent(
91
98
);
92
99
```
93
100
101
+ ## Single Child
102
+
103
+ With ` React.PropTypes.component ` you can specify that only a single child can be passed to
104
+ a component as children.
105
+
106
+ ``` javascript
107
+ var MyComponent = React .createClass ({
108
+ propTypes: {
109
+ children: React .PropTypes .component .isRequired
110
+ },
111
+
112
+ render : function () {
113
+ return
114
+ < div>
115
+ {this .props .children } // This must be exactly one element or it will throw.
116
+ < / div> ;
117
+ }
118
+
119
+ });
120
+ ```
94
121
95
122
## Mixins
96
123
You can’t perform that action at this time.
0 commit comments