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

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

I finished react redux but still console error still reamins

Hi everyone,

So I finished the React Redux course and the up to date repo is on GitHub, but the scoreboard component is still throwing a property error for the map property. It's been bugging me since Thursday and won't go away no matter what I try.

npm start successfully starts the server but the error is in the console. Please help me flush it out? :)

GitHub: https://bitbucket.org/jg_digitalMedia/react-redux

Uncaught TypeError: Cannot read property 'map' of undefined
    at Scoreboard.render (Scoreboard.js:23)
    at ReactCompositeComponent.js:795
    at measureLifeCyclePerf (ReactCompositeComponent.js:75)
    at ReactCompositeComponentWrapper._renderValidatedComponentWithoutOwnerOrContext (ReactCompositeComponent.js:794)
    at ReactCompositeComponentWrapper._renderValidatedComponent (ReactCompositeComponent.js:821)
    at ReactCompositeComponentWrapper.performInitialMount (ReactCompositeComponent.js:361)
    at ReactCompositeComponentWrapper.mountComponent (ReactCompositeComponent.js:257)
    at Object.mountComponent (ReactReconciler.js:45)
    at ReactCompositeComponentWrapper.performInitialMount (ReactCompositeComponent.js:370)
    at ReactCompositeComponentWrapper.mountComponent (ReactCompositeComponent.js:257)
:8080/favicon.ico Failed to load resource: the server responded with a status of 404 (Not Found)
scoreboard.js
import React, {Component, PropTypes} from 'react';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import * as PlayerActionCreators from '../actions/player';
import Player from '../components/Player';
import Header from '../components/Header';
import AddPlayerForm from '../components/AddPlayerForm';


class Scoreboard extends Component {

    static PropTypes = {
        players: PropTypes.array.isRequired
    };

    render() {

        const { dispatch, players } = this.props;
        const addPlayer = bindActionCreators(PlayerActionCreators.addPlayer, dispatch);
        const removePlayer = bindActionCreators(PlayerActionCreators.removePlayer, dispatch);
        const updatePlayerScore = bindActionCreators(PlayerActionCreators.updatePlayerScore, dispatch);

        const playerComponents = players.map((player, index) => (
                <Player
                    index={index}
                    name={player.name}
                    score={player.score}
                    key={player.name}
                    updatePlayerScore={updatePlayerScore}
                    removePlayer={removePlayer}
                />
            ));


        return (
          <div className="scoreboard">
            <Header players = { players } />
            <div className="players">
                { playerComponents }
            </div>
            <AddPlayerForm addPlayer={addPlayer} />
          </div>
        );
      }
}

const mapStateToProps = state => ( {
        players: state.players,
    }

);

export default connect(mapStateToProps)(Scoreboard);