title: Redux reducer isn't returning the updated state to UI
body: <p>I have a reducer case, and this case is supposed to add a comment, and update the UI with the new comment, </p>
  
  <p>Pretty much you add a comment, and it will show under the rest of comments once you do, the logic is not returning the new state for some reason.</p>
  
  <p>What could be the cause of this ? And to be honest im unsure of what im doing, im fairly new when it comes to reducer normalizer state updates.</p>
  
  <p>Only on refresh i see the new comment.  </p>
  
  <pre><code>const initialState = {
    allIds:[],
    byId:{},
  };
  
  const allIds = (state = initialState.allIds, action) =&gt; {
    switch (action.type) {
      case  FETCH_IMAGES_SUCCESS:
        return action.images.reduce((nextState, image) =&gt; {
          if (nextState.indexOf(image.id) === -1) {
            nextState.push(image.id);
          }
          return nextState;
        }, [...state]);
        case UPLOAD_IMAGE_SUCCESS:
          console.log(action.data)
          return [action.data.id, ...state];
  
        case POST_COMMENT_SUCCESS:
          console.log(action)
          return [action.data.id, ...state];
      default:
        return state;
    }
  }
  const image = (state = {}, action) =&gt; {
    switch (action.type) {
      case POST_COMMENT_SUCCESS:
        return [...state.comments, action.data, ...state.comments]
  
      default:
        return state;
    }
  }
  
  const byId = (state = initialState.byId, action) =&gt; {
    switch (action.type) {
      case FETCH_IMAGES_SUCCESS:
        return action.images.reduce((nextState, image) =&gt; {
          nextState[image.id] = image;
  
          return nextState;
        }, {...state});
      case POST_COMMENT_SUCCESS:
        console.log(action.data) // renders new commnent
        return {
          ...state,
          ...state.comments,
          [action.data.id]: action.data,
  
        }
      case UPLOAD_IMAGE_SUCCESS:
        console.log(action)
        return {
          ...state,
          [action.data.id]: action.data,
        };
      default:
        return state;
    }
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/GXQFW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GXQFW.png" alt="enter image description here"></a></p>