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 trialAlex Hort-Francis
17,074 Points`props.id` vs `id` in the click event handler callback function.
At 1:00, I'm guessing that using props.id
wouldn't have worked; as in:
<button className="counter-action decrement" onClick={() => props.changeScore(props.id, -1)}>
1 Answer
Bella Bradbury
Front End Web Development Techdegree Graduate 32,790 PointsAlex,
That would also be acceptable! It really comes down to the fact that because you're using props.id
multiple times, it makes sense to put it in a variable so that you're not repeating yourself. This would also make it much easier to change your code in the future if needed because you'd only have to change it in one place (the variable) as opposed to at every instance in your code.
Hope this helps!