Tweak propTypes examples for clarity in oneOfType
Ben Alpert committed
Feb 26, 2014 at 15:03 UTC
298a05517e71e9f18ad55f906e020e1272ac30b9
1 file changed
+6
-5
docs/docs/05-reusable-components.md
+6
-5
@@ -33,6 +33,10 @@ React.createClass({
33
// A React component.
34
optionalComponent: React.PropTypes.component,
35
36
+ // You can also declare that a prop is an instance of a class. This uses
37
+ // JS's instanceof operator.
38
+ optionalMessage: React.PropTypes.instanceOf(Message),
39
+
40
// You can ensure that your prop is limited to specific values by treating
41
// it as an enum.
42
optionalEnum: React.PropTypes.oneOf(['News', 'Photos']),
@@ -40,7 +44,8 @@ React.createClass({
44
// An object that could be one of many types
45
optionalUnion: React.PropTypes.oneOfType([
46
React.PropTypes.string,
43
- React.PropTypes.number
47
+ React.PropTypes.number,
48
+ React.PropTypes.instanceOf(Message)
49
]),
50
51
// An array of a certain type
@@ -52,10 +57,6 @@ React.createClass({
57
fontSize: React.PropTypes.number
58
}),
59
55
- // You can also declare that a prop is an instance of a class. This uses
56
- // JS's instanceof operator.
57
- someClass: React.PropTypes.instanceOf(SomeClass),
58
-
60
// You can chain any of the above with isRequired to make sure a warning is
61
// shown if the prop isn't provided.
62
requiredFunc: React.PropTypes.func.isRequired,