title: Do I have to return state in a Redux Reducer?
body: <p>I am having trouble wrapping my head around the way a redux-reducer works in JavaScript.</p>
  
  <p>Here is the example I am working with: </p>
  
  <pre><code>const intitialState = {
    profile: null,
    profiles: [],
    repos: [],
    loading: true,
    error: {},
  };
  
  export default function (state = intitialState, action) {
    const { type, payload } = action;
  
    switch (type) {
      case GET_PROFILE:
        return {
          ...state,
          profile: payload,
          loading: false,
        };
      case PROFILE_ERROR:
        return {
          ...state,
          error: payload,
          loading: false,
        };
      default:
        return state;
    }
  }
  </code></pre>
  
  <p>Which of these assumptions is correct, if either, about this reducer?</p>
  
  <p>A) When GET_PROFILE is triggered, it returns '...state' as the initial state so that the redux dev tools can compare states.</p>
  
  <p>B) When GET_PROFILE is triggered, it is really just filling in the values into the object that I didn't explicitly list. As in the return really looks like this:</p>
  
  <pre><code>return {
          profiles: profiles,
          repos: repos,
          error: error,
          profile: payload,
          loading: false,
        };
  </code></pre>
  
  <p>And if A or B is true, then what happens if I do not return ...state as the first one, will this mess up the other objects?</p>
  
  <p>Edit: And where exactly does it  return to?</p>