Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Hiep Nguyen
Hiep Nguyen
420 Points

Hey, it's my code. I ran well without changing "props" to "state"

Hey, it's my code. I ran well without changing "props" to "state" but having trouble when changing "Need prop initialPlayers to be specified in Application"

var Application = React.createClass({ propTypes: { title: React.PropTypes.string, initialPlayers: React.PropTypes.arrayOf(React.PropTypes.shape({ name: React.PropTypes.string.isRequired, score: React.PropTypes.number.isRequired, id: React.PropTypes.number.isRequired, })), },

getDefaultProps: function() { return{ title: "Scoreboard", } },

getInitialState: function() { return{ players: this.props.initialPlayers, }; },

render: function() { return ( <div className="scoreboard"> <Header title={this.props.title} />

  <div className="players">
    {this.props.players.map(function(player){
      return <Player name={player.name} score ={player.score} key={player.id} />
    })}
  </div>
</div>

); } });

Steven Parker
Steven Parker
221,293 Points

Is this part of a course challenge? A link to the challenge page would be very helpful.

Formatting your could would also be nice, see the Markdown Cheatsheet pop-up below the "Add an Answer" section for instructions. :arrow_heading_down: