[Docs] new PropType behavior
(Killed the TODOs since they're no longer valid).
Cheng Lou committed
Apr 9, 2014 at 16:49 UTC
acc9bde1f35e57be308050ec066e2baeda84f0d2
2 files changed
+6
-8
docs/docs/05-reusable-components.md
+6
-4
@@ -57,17 +57,19 @@ React.createClass({
57
fontSize: React.PropTypes.number
58
}),
59
60
- // You can chain any of the above with isRequired to make sure a warning is
61
- // shown if the prop isn't provided.
60
+ // You can chain any of the above with `isRequired` to make sure a warning
61
+ // is shown if the prop isn't provided.
62
requiredFunc: React.PropTypes.func.isRequired,
63
64
// A value of any data type
65
requiredAny: React.PropTypes.any.isRequired,
66
67
- // You can also specify a custom validator.
67
+ // You can also specify a custom validator. It should return an Error
68
+ // object if the validation fails. Don't `console.warn` or throw, as this
69
+ // won't work inside `oneOfType`.
70
customProp: function(props, propName, componentName) {
71
if (!/matchme/.test(props[propName])) {
70
- console.warn('Validation failed!');
72
+ return new Error('Validation failed!');
73
}
74
}
75
},
docs/docs/ref-03-component-specs.md
-4
@@ -53,8 +53,6 @@ object propTypes
53
54
The `propTypes` object allows you to validate props being passed to your components. For more information about `propTypes`, see [Reusable Components](/react/docs/reusable-components.html).
55
56
-<!-- TODO: Document propTypes here directly. -->
57
-
56
57
### mixins
58
@@ -64,8 +62,6 @@ array mixins
62
63
The `mixins` array allows you to use mixins to share behavior among multiple components. For more information about mixins, see [Reusable Components](/react/docs/reusable-components.html).
64
67
-<!-- TODO: Document mixins here directly. -->
68
-
65
66
### statics
67