I was into functional Javascript previously, Recently I started with Object oriented Javascript and React Library. This question is more of understanding the code.
Why below code don't work
class MyComponent extends React.Component{ propTypes : { name: React.PropTypes.string.isReequired, location: React.PropTypes.string } render(){ return( <h1>Hello This is {this.props.name} and I live in {this.props.location}</h1> ); } } ReactDOM.render( <MyComponent name="Node" location="DOM"/>, document.getElementById('root') ); Whereas this code works,
class MyComponent extends React.Component{ render(){ return( <h1>Hello This is {this.props.name} and I live in {this.props.location}</h1> ); } } MyComponent.propTypes = { name: React.PropTypes.string.isReequired, location: React.PropTypes.string } ReactDOM.render( <MyComponent name="Node" location="DOM"/>, document.getElementById('root') ); Can someone help me understand this? Thanks.