title: Redux State count return
body: <p>I'm trying to build out a feature in my React application showing num of comments for a specific post. Since I don't have this information from backend ill try to make a <code>.length</code>on the returned state.</p>
  
  <p>However, it seems like I have built out the reducer in a faulty way but I'm not sure whats wrong with it. Right now I'm just receiving undefined.</p>
  
  <p>Built up as following</p>
  
  <h3>Action</h3>
  
  <pre><code>    export function getPostComments(id) {
      const request = API.fetchPostComments(id)
  
      return (dispatch) =&gt; {
          request.then(({data}) =&gt; {
              dispatch({type: COMMENTS_GET_POSTCOMMENTS, payload: data})
          });
      };
  }
  </code></pre>
  
  <h3>Reducer</h3>
  
  <pre><code>export default function(state = {}, action) {
    switch (action.type){
          case COMMENTS_GET_POSTCOMMENTS:
        return {...state, ...action.payload}
  </code></pre>
  
  <h3>Component</h3>
  
  <pre><code>componentWillMount() {
          this.props.getPostComments(this.props.id);
      }
  
  ....
  
  &lt;span&gt;{`comments ${this.props.comments.length}`}&lt;/span&gt;
  
  ....
  
  
  function mapStateToProps(state) {
      return {
          comments: state.comments,
  
      }
  }
  
  
  export default connect(mapStateToProps, {postPostVote, getPostComments})(PostComponent);
  </code></pre>
  
  <h3>EDIT</h3>
  
  <p>I am retrieving information from the server if I change my reducer to be <code>return action.payload</code>I will first receive a comment number of 2 but then this gets wiped replacing it with a 0 since the last post in the list doesn't have any comments. So I'm overwriting here? And that most be wrong aswell     </p>
  
  <p>Repo : <a href="https://github.com/petterostergren/readable" rel="nofollow noreferrer">https://github.com/petterostergren/readable</a></p>
  
  <p><em>Thanks for now!</em></p>