Tweak propTypes examples for clarity in oneOfType

This commit is contained in:
Ben Alpert
2014-02-26 15:04:11 -08:00
parent b9ca151242
commit 78cc5600fb
+6 -5
View File
@@ -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,