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 trialBrian Patrick
Courses Plus Student 2,770 PointsGetting syntax error for Player.propTypes section. Help.
I get this in dev tools.
Unexpected token (30:6) 28 | 29 | Player.propTypes = {
30 | name: React.PropTypes.string.isRequired, | ^ 31 | score: React.PropTypes.number.isRequired, 32 | } 33 |
function Player(props) {
return(
<div className="player">
<div className="player-name">
{props.name}
</div>
<div className="player-score">
<div className="counter">
<button className="counter-action decrement"> - </button>
<div className="counter-score"> {props.score} </div>
<button className="counter-action increment"> + </button>
</div>
</div>
);
}
Player.propTypes = {
name: React.PropTypes.string.isRequired,
score: React.PropTypes.number.isRequired,
}
1 Answer
Andrew Hickman
Full Stack JavaScript Techdegree Student 10,013 PointsHey there Brian! You are getting a syntax error because <div className="player-score"> is not closed. React is attempting to render invalid JSX. Simply add a closing tag:
function Player(props) {
return(
<div className="player">
<div className="player-name">
{props.name}
</div>
<div className="player-score">
<div className="counter">
<button className="counter-action decrement"> - </button>
<div className="counter-score"> {props.score} </div>
<button className="counter-action increment"> + </button>
</div>
// CLOSE DIV.PLAYER-SCORE:
</div>
</div>
);
}
Brian Patrick
Courses Plus Student 2,770 PointsBrian Patrick
Courses Plus Student 2,770 PointsI commented out the Player.propTypes object and I get the same errors with
The code was working before I added the Player function.