From ff6cb41f091507f4191f9ebf507bd63668916747 Mon Sep 17 00:00:00 2001 From: Cheng Lou Date: Wed, 9 Apr 2014 16:49:40 -0700 Subject: [PATCH] [Docs] new PropType behavior (Killed the TODOs since they're no longer valid). --- docs/05-reusable-components.md | 10 ++++++---- docs/ref-03-component-specs.md | 4 ---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/docs/05-reusable-components.md b/docs/05-reusable-components.md index 5dd0e930..89dfba5d 100644 --- a/docs/05-reusable-components.md +++ b/docs/05-reusable-components.md @@ -57,17 +57,19 @@ React.createClass({ fontSize: React.PropTypes.number }), - // You can chain any of the above with isRequired to make sure a warning is - // shown if the prop isn't provided. + // You can chain any of the above with `isRequired` to make sure a warning + // is shown if the prop isn't provided. requiredFunc: React.PropTypes.func.isRequired, // A value of any data type requiredAny: React.PropTypes.any.isRequired, - // You can also specify a custom validator. + // You can also specify a custom validator. It should return an Error + // object if the validation fails. Don't `console.warn` or throw, as this + // won't work inside `oneOfType`. customProp: function(props, propName, componentName) { if (!/matchme/.test(props[propName])) { - console.warn('Validation failed!'); + return new Error('Validation failed!'); } } }, diff --git a/docs/ref-03-component-specs.md b/docs/ref-03-component-specs.md index 127b2ebf..53388092 100644 --- a/docs/ref-03-component-specs.md +++ b/docs/ref-03-component-specs.md @@ -53,8 +53,6 @@ object propTypes 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). - - ### mixins @@ -64,8 +62,6 @@ array mixins 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). - - ### statics