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 Components (2018) Managing State and Data Flow Communicating Between Components

Anthony Ogounchi
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Anthony Ogounchi
Full Stack JavaScript Techdegree Graduate 14,594 Points

I am getting this error TypeError: props.changeScore is not a function

I am asking the question again because I am getting the same error and even though the question has already been asked previously, there was no answer provided to it.

import React from 'react';

const Counter = (props) => {

  let index = props.index;

  return (
    <div className="counter">
      <button className="counter-action decrement" onClick={() => props.changeScore(index, -1)}> - </button>
      <span className="counter-score">{  props.score }</span>
      <button className="counter-action increment" onClick={() => props.changeScore(index, +1)}> + </button>
    </div>
  );
}

export default Counter;

The code you have appears to match the video. You will probably have to post more than this. Can you post App.js?

1 Answer