Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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