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

Skip to content

Commit b66fbde

Browse files
cpojervjeux
authored andcommitted
Update propTypes documentation.
1 parent 8c8841c commit b66fbde

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

docs/docs/05-reusable-components.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ When designing interfaces, break down the common design elements (buttons, form
1212

1313
## Prop Validation
1414

15-
As your app grows it's helpful to ensure that your components are used correctly. We do this by allowing you to specify `propTypes`. `React.PropTypes` exports a range of validators that can be used to make sure the data you receive is valid. When an invalid value is provided for a prop, an error will be thrown. Here is an example documenting the different validators provided:
15+
As your app grows it's helpful to ensure that your components are used correctly. We do this by allowing you to specify `propTypes`. `React.PropTypes` exports a range of validators that can be used to make sure the data you receive is valid. When an invalid value is provided for a prop, a warning will be shown in the JavaScript console. Note that for performance reasons `propTypes` is only checked in development mode. Here is an example documenting the different validators provided:
1616

1717
```javascript
1818
React.createClass({
@@ -34,14 +34,14 @@ React.createClass({
3434
// JS's instanceof operator.
3535
someClass: React.PropTypes.instanceOf(SomeClass),
3636

37-
// You can chain any of the above with isRequired to make sure an error is
38-
// thrown if the prop isn't provided.
37+
// You can chain any of the above with isRequired to make sure a warning is
38+
// shown if the prop isn't provided.
3939
requiredFunc: React.PropTypes.func.isRequired
4040

4141
// You can also specify a custom validator.
4242
customProp: function(props, propName, componentName) {
4343
if (!/matchme/.test(props[propName])) {
44-
throw new Error('Validation failed!')
44+
console.warn('Validation failed!');
4545
}
4646
}
4747
},

0 commit comments

Comments
 (0)