JavaScript React Basics (retired) Thinking in Components PropTypes and DefaultProps

Sergio Lopez
Sergio Lopez
2,892 Points

For some reason the console is not showing the PropType error when I pass a number instead of a string

As defined on the code. The React devtools on chrome or firefox does not show the console warning

var App = function(props){

return( <div className="application"> <div className="header"> <h1> {props.title} </h1> </div> <div className="players"> <div className="player-name"> Tom Cole </div> <div className="player-score"> <div className="counter"> <button className="button counter-action decrement">-</button> <div className="counter-score"> 5 </div> <button className="button counter-action increment">+</button> </div> </div> </div> </div> );

}

App.propTypes = { title : React.PropTypes.string.isRequired, }

ReactDOM.render(<App title={3} />, document.getElementById('container'));

2 Answers

Sergio Lopez
Sergio Lopez
2,892 Points

The reason is because I was using the .min version of the react.js file instead of the dev version.

Thanks.

I had the same issue working locally (not in the Treehouse Workspace in the browser). Resolved by using https://cdnjs.cloudflare.com/ajax/libs/react/15.4.1/react.js instead of https://cdnjs.cloudflare.com/ajax/libs/react/15.4.1/react.min.js