Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 78cc560

Browse files
committed
Tweak propTypes examples for clarity in oneOfType
1 parent b9ca151 commit 78cc560

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

docs/docs/05-reusable-components.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,19 @@ React.createClass({
3333
// A React component.
3434
optionalComponent: React.PropTypes.component,
3535

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+
3640
// You can ensure that your prop is limited to specific values by treating
3741
// it as an enum.
3842
optionalEnum: React.PropTypes.oneOf(['News', 'Photos']),
3943

4044
// An object that could be one of many types
4145
optionalUnion: React.PropTypes.oneOfType([
4246
React.PropTypes.string,
43-
React.PropTypes.number
47+
React.PropTypes.number,
48+
React.PropTypes.instanceOf(Message)
4449
]),
4550

4651
// An array of a certain type
@@ -52,10 +57,6 @@ React.createClass({
5257
fontSize: React.PropTypes.number
5358
}),
5459

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-
5960
// You can chain any of the above with isRequired to make sure a warning is
6061
// shown if the prop isn't provided.
6162
requiredFunc: React.PropTypes.func.isRequired,

0 commit comments

Comments
 (0)