Skip to content

Commit a15b7d3

Browse files
author
Matt Calthrop
committed
Use propTypes to define required props
1 parent 000b4e2 commit a15b7d3

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

public/scripts/tutorial20.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ var CommentForm = React.createClass({
4141
author: '',
4242
text: ''
4343
},
44+
propTypes: {
45+
onCommentSubmit: React.PropTypes.func.isRequired
46+
},
4447
getInitialState: function () {
4548
return _.clone(this.initialState);
4649
},
@@ -63,12 +66,6 @@ var CommentForm = React.createClass({
6366
this.setState(this.getInitialState());
6467
}
6568
},
66-
componentDidMount: function () {
67-
// check if required properties have been set
68-
if (!this.props.onCommentSubmit) {
69-
throw new Error('onCommentSubmit property not set');
70-
}
71-
},
7269
render: function () {
7370
return (
7471
<form

0 commit comments

Comments
 (0)