From 78cc5600fb04b031c9383d6bc0cbed3196371003 Mon Sep 17 00:00:00 2001 From: Ben Alpert Date: Wed, 26 Feb 2014 15:03:47 -0800 Subject: [PATCH] Tweak propTypes examples for clarity in oneOfType --- docs/docs/05-reusable-components.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/docs/05-reusable-components.md b/docs/docs/05-reusable-components.md index 34d55e9b0d..126f58e170 100644 --- a/docs/docs/05-reusable-components.md +++ b/docs/docs/05-reusable-components.md @@ -33,6 +33,10 @@ React.createClass({ // A React component. optionalComponent: React.PropTypes.component, + // You can also declare that a prop is an instance of a class. This uses + // JS's instanceof operator. + optionalMessage: React.PropTypes.instanceOf(Message), + // You can ensure that your prop is limited to specific values by treating // it as an enum. optionalEnum: React.PropTypes.oneOf(['News', 'Photos']), @@ -40,7 +44,8 @@ React.createClass({ // An object that could be one of many types optionalUnion: React.PropTypes.oneOfType([ React.PropTypes.string, - React.PropTypes.number + React.PropTypes.number, + React.PropTypes.instanceOf(Message) ]), // An array of a certain type @@ -52,10 +57,6 @@ React.createClass({ fontSize: React.PropTypes.number }), - // You can also declare that a prop is an instance of a class. This uses - // JS's instanceof operator. - someClass: React.PropTypes.instanceOf(SomeClass), - // 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,