title: Redux Action data needed for another Action
body: <p>so I have an Action, which fetches some data from rest. In a component, i need this data from the fetch, which is set in store. 
  I use this data then like <code>someFunc(this.props.data)</code> in <code>componentDidMount()</code>. Afterwards i give the return value of <code>someFunc</code> an another Action, which does something with this data and also sets it in store.</p>
  
  <p>My only idea is, to give <code>someFunc</code> to the Action as a callback and call this right after the first data is fetched. So i have 2 dispatched in one action.</p>
  
  <p>I hope you guys understand what i mean. Is there a better way to do this?</p>
  
  <h1>Edit</h1>
  
  <p>In Component1 i dispatch an Action, which loads data i need to the store. In Component2 i dispatch another Action, which gets his value from <code>someFunc</code> function. But <code>someFunc</code> gets the data from the first Action, so the data is undefined when i call <code>someFunc</code>, because the data isn't set in the store yet.</p>
  
  <p>More clear yet?</p>
  
  <h1>Component1</h1>
  
  <pre><code>componentDidMount(){
          this.props.dataLoadAction()   //action for the fetch i told
  }
  
  const mapDispatchToProps = (dispatch) =&gt; {
  
      return {
          dataLoadAction: () =&gt; {
              dispatch(dataLoadAction())
          }
      }
  };
  
  export default connect(null, mapDispatchToProps)(Component1);
  </code></pre>
  
  <h1>Component2</h1>
  
  <pre><code>componentDidMount(){
          this.props.changeDataAction(this.someFunc(this.props.data))
  }
  
  render(){
          return (
              &lt;div&gt;
                  {this.props.otherData}
              &lt;/div&gt;
          )
      }
  
  const mapStateToProps = (state) =&gt; {
  
      return {
          otherData: state.someReducer.otherData,
          data: state.someReducer.data,
      }
  };
  
  const mapDispatchToProps = (dispatch) =&gt; {
  
      return {
          changeDataAction: (changedData) =&gt; {
              dispatch(changeDataAction(changedData))
          }
      }
  };
  
  export default connect(mapStateToProps, mapDispatchToProps)(Component2);
  </code></pre>
  
  <h1>Actions</h1>
  
  <pre><code>export function dataLoadAction(){
      return dispatch =&gt; {
  
      HttpRequest.getJson("some url", json =&gt; {
  
              dispatch(
                  {
                      type: 'DATA_LOADED',
                      payload: {
                          data: json
                      }
                  }
              )
          });
      });
  };
  </code></pre>
  
  <p>}</p>
  
  <pre><code>export function changeDataAction(changedData){
      return dispatch =&gt; {
  
          dispatch(
              {
                  type: 'LOAD_CHANGEDDATA',
                  payload: mappedVis
              }
          )
  
      };
  }
  </code></pre>