title: React Redux: How to call multiple dependent actions in sequence
body: <p>I'm trying to chain two calls in a single action using a thunk, but it doesn't seem to work as expected. I need the ID value from the first action to call the second one.</p>
  
  <p>Actions look like this:</p>
  
  <pre><code>export const getParentRecords = filterId =&gt; {
      return (dispatch, getState) =&gt; {
          let headers = {
              filter_id: filterId
          };
          const request = axios({
              method: "GET",
              url: `https://myapi.com/v1/parent-records`,
              headers: headers
          });
          dispatch({
              type: GET_PARENT_RECORDS,
              payload: request
          });
      };
  };
  
  export const getChildRecords = (parentId = null) =&gt; {
      let url = `https://myapi.com/v1/child-records`;
      if (parentId) {
          url = `https://myapi.com/v1/child-records/?parent_id=${parentId}`;
      }
      return (dispatch, getState) =&gt; {
          let headers = {
              //etc...
          };
          const request = axios({
              method: "GET",
              url: url,
              headers: headers
          });
          dispatch({
              type: GET_CHILD_RECORDS,
              payload: request
          });
      };
  };
  
  export const getAllRecords = filterId =&gt; {
      return (dispatch, getState) =&gt; {
          dispatch(getParentRecords(filterId);
          let { parentRecords } = getState();
          let defaultParent = parentRecords.filter(p =&gt; p.is_default === true)[0];
          dispatch(getChildRecords(defaultParent.parent_id));
      };
  };
  </code></pre>
  
  <p>In calling component:</p>
  
  <pre><code>const mapStateToProps = state =&gt; {
      return {
          parentRecords: state.parentRecords,
          childRecords: state.childRecords
      };
  };
  
  export default connect(mapStateToProps, { getAllRecords })(MyComponent);
  </code></pre>
  
  <p>Problem is; dispatching the first action doesn't seem to be doing anything. When I call getState() afterwards, the data isn't there. The parentRecords variable in getAllRecords is always empty.</p>
  
  <p>I'm really not sure what to do with this. Pretty common scenario but haven't found a way through it.</p>