title: React Redux not able to insert an object into nested array
body: <p>Im trying to insert object into particular object(i.e list of object ). Below is the code.</p>
  <pre><code>import MESSAGES from '../actions/Messages';
  import update from 'immutability-helper';
  
  const chatReducer = (state = [], { type, payload }) =&gt; {
      switch (type) {
          case CHATS:
              // state = [...state, payload];
              // return state;
              return state, payload;
          case MESSAGES:
              let index = state.findIndex(
                  chat =&gt;  chat.chatId === payload.chatId);
              const conn = state[index];
              const messages = [...conn.messages, payload];
              const newState = state.slice();
              newState[index] = { ...conn, messages };
              //console.log(&quot;ne &quot;, newState)
              return newState;
          default:
              return state
      };
  };
  
  export default chatReducer;
  </code></pre>
  <p>Here am just finding the object based on the id and inserting the payload into messages array which is not working.</p>