Update deprecated propTypes

This commit is contained in:
Raymond Ha
2014-10-29 21:00:32 -07:00
parent 7071d1c316
commit 92d171a4fc
2 changed files with 14 additions and 14 deletions
+6 -6
View File
@@ -25,12 +25,12 @@ React.createClass({
optionalObject: React.PropTypes.object,
optionalString: React.PropTypes.string,
// Anything that can be rendered: numbers, strings, components or an array
// Anything that can be rendered: numbers, strings, elements or an array
// containing these types.
optionalRenderable: React.PropTypes.renderable,
optionalNode: React.PropTypes.node,
// A React component.
optionalComponent: React.PropTypes.component,
// A React element.
optionalElement: React.PropTypes.element,
// You can also declare that a prop is an instance of a class. This uses
// JS's instanceof operator.
@@ -120,13 +120,13 @@ React.render(
## Single Child
With `React.PropTypes.component` you can specify that only a single child can be passed to
With `React.PropTypes.element` 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
children: React.PropTypes.element.isRequired
},
render: function() {
+8 -8
View File
@@ -18,7 +18,7 @@ exports.setup = function(){
number: React.PropTypes.number,
string: React.PropTypes.string.isRequired,
func: React.PropTypes.func.isRequired,
renderable: React.PropTypes.renderable.isRequired,
node: React.PropTypes.node.isRequired,
instanceOf: React.PropTypes.instanceOf(Thing).isRequired
},
render: function() {
@@ -33,14 +33,14 @@ exports.setup = function(){
number: React.PropTypes.number,
string: React.PropTypes.string.isRequired,
func: React.PropTypes.func.isRequired,
renderable: React.PropTypes.renderable.isRequired,
renderable2: React.PropTypes.renderable.isRequired,
node: React.PropTypes.node.isRequired,
node2: React.PropTypes.node.isRequired,
instanceOf: React.PropTypes.instanceOf(Thing).isRequired,
component: React.PropTypes.component.isRequired
element: React.PropTypes.element.isRequired
},
render: function(){
return React.DOM.li(null,
this.props.number + this.props.string + this.props.renderable
this.props.number + this.props.string + this.props.node
);
}
});
@@ -63,10 +63,10 @@ exports.fn = function(){
number: Math.random(),
string: 'banana banana banana',
func: function() { return 'this is a function'; },
renderable: 'renderable string',
renderable2: [MyReactComponent(), 'a string'],
node: 'renderable string',
node2: [MyReactComponent(), 'a string'],
instanceOf: new Thing,
component: MyReactComponent()
element: MyReactComponent()
}));
};