title: Why my state is underfined even when I've set it as an empty array by default?
body: <p>I've got "Cannot read property 'map' of undefined" error on the line</p>
  
  <pre><code>{props.decks.map((deck, i) =&gt; 
  </code></pre>
  
  <p>of my Sidebar component</p>
  
  <pre><code>import React from 'react';
  import ReactDOM from 'react-dom';
  import { connect } from 'react-redux';
  import { addDeck, showAddDeck, hideAddDeck } from '../actions';
  
  const mapStateToProps = ({decks, addingDeck}) =&gt; ({
    decks,
    addingDeck
  });
  
  const mapDispatchToProps = dispatch =&gt; ({
    addDeck: name =&gt; dispatch(addDeck(name)),
    showAddDeck: () =&gt; dispatch(showAddDeck()),
    hideAddDeck: () =&gt; dispatch(hideAddDeck())
  });
  
  class Sidebar extends React.Component {
    constructor(props) {
      super(props);
      this.createDeck = this.createDeck.bind(this);
    }
    componentDidUpdate() {
      var el = ReactDOM.findDOMNode(this.refs.add);
      if (el) el.focus();
    }
    render() {
      let props = this.props;
      return  (
        &lt;div className='sidebar'&gt;
          &lt;h2&gt; All Decks &lt;/h2&gt;
          &lt;button onClick={ e =&gt; this.props.showAddDeck() }&gt;
            New Decks
          &lt;/button&gt;
          &lt;ul&gt;
            {props.decks.map((deck, i) =&gt; 
              &lt;li key={i}&gt; {deck.name} &lt;/li&gt;
              )}
          &lt;/ul&gt;
          {props.addingDeck &amp;&amp; &lt;input ref='add' onKeyPress={this.createDeck} /&gt;}
        &lt;/div&gt;);
    }
    createDeck(evt) {
      const ENTER = 13;
      if (evt.which !== ENTER) return;
      var name = ReactDOM.findDOMNode(this.refs.add).value;
      this.props.addDeck(name);
      this.props.hideAddDeck();
    }
  };
  
  export default connect(mapStateToProps, mapDispatchToProps)(Sidebar);
  </code></pre>
  
  <p>I've set the state as an empty array by default in reducers.js</p>
  
  <p>so I can't understand why my props.decks is underfined</p>
  
  <p>is it something with ES6?</p>
  
  <pre><code>export const decks = (state, action) =&gt; {
    switch (action.type) {
      case 'ADD_DECK':
        let newDeck = { name: action.data, id: +new Date };
        return state.concat([newDeck]);
      default: 
        return state || [];
    }
  };
  </code></pre>
  
  <p>Here is my index.js</p>
  
  <pre><code>import React from 'react';
  import ReactDOM from 'react-dom';
  import { createStore, combineReducers } from 'redux';
  import { Provider } from 'react-redux';
  import { Router, Route, browserHistory } from 'react-router';
  import { syncHistoryWithStore, routerReducer, ConnectedRouter  } from 'react-router-redux';
  import * as reducers from './reducers';
  import './index.css';
  import App from './components/App';
  
  
  const store = createStore(combineReducers({reducers,
      routing: routerReducer}));
  const history = syncHistoryWithStore(browserHistory, store);
  
  function run () {
    let state = store.getState();
    ReactDOM.render(
      &lt;Provider store={store}&gt;
        &lt;Router history={history}&gt;
          &lt;Route path='/' component={App}&gt;&lt;/Route&gt;
        &lt;/Router&gt;
      &lt;/Provider&gt;, document.getElementById('root'));
  }
  
  run();
  store.subscribe(run);
  </code></pre>
  
  <p>and App.js</p>
  
  <pre><code>import React from 'react';
  import Sidebar from './Sidebar';
  
  const App = ( props ) =&gt; {
    return (
      &lt;div className='app'&gt;
        &lt;Sidebar /&gt;
        { props.children }
      &lt;/div&gt;);
  };
  
  export default App;
  </code></pre>
  
  <p>and package.json</p>
  
  <pre><code>{
    "name": "flashcard-app-3",
    "version": "0.1.0",
    "private": true,
    "dependencies": {
      "babel-core": "^6.26.0",
      "babel-preset-es2015": "^6.24.1",
      "babel-preset-react": "^6.24.1",
      "babelify": "^8.0.0",
      "fuzzysearch": "^1.0.3",
      "history": "^4.7.2",
      "live-server": "^1.2.0",
      "prop-types": "^15.6.0",
      "react": "^15.0.0",
      "react-dom": "^15.0.0",
      "react-redux": "^4.4.1",
      "react-router": "^2.0.1",
      "react-router-dom": "^4.2.2",
      "react-router-redux": "^4.0.1",
      "redux": "^3.3.1",
      "watchify": "^3.9.0",
      "react-scripts": "1.0.17"
    },
    "scripts": {
      "start": "set PORT=3001 &amp;&amp; react-scripts start",
      "build": "react-scripts build",
      "test": "react-scripts test --env=jsdom",
      "eject": "react-scripts eject"
    }
  }
  </code></pre>