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 trialcody gamble
13,312 PointsI am getting this error TypeError: props.changeScore is not a function
There has not been a clear answer on any of the previous questions with the same name,
import React from 'react';
const Counter = (props) => {
return (
<div className="counter">
<button className="counter-action decrement" onClick={() => props.changeScore(-1)}> - </button>
<span className="counter-score">{ props.score }</span>
<button className="counter-action increment" onClick={() => props.changeScore(1)}> + </button>
</div>
);
}
export default Counter;
2 Answers
cody gamble
13,312 PointsAh HA! I found my problem
{/* Players list */}
{this.state.players.map( player =>
<Player
name={player.name}
score={player.score}
id={player.id}
key={player.id.toString()}
changeScore={this.handleScoreChange}
removePlayer={this.handleRemovePlayer}
/>
)}
</div>
);
}
}
the changeScore prop in the player component I had capitalized the first letter by accident
Chris Adams
Front End Web Development Techdegree Graduate 29,423 PointsI encountered a similar issue, but like the OP, I had also included a typo in my code. The video runs quite fast, so I would recommend that anyone following along takes the time to make sure all their code matches what Guil writes. I've slowed the video down quite a bit now.
cody gamble
13,312 Pointscody gamble
13,312 PointsOne discussion OP said he found an error in his App.js, but he never mentioned what it was