Actions must be plain Objects in React/Redux?
<p>the problem I'm running into is <code>Actions must be plain objects</code> when passing data through my action creators. Basically I'm trying to capture user input through the click of a button, and <strong>based on what button (view) is clicked</strong> the <code>event.target.innerHTML</code> is passed to the action creator <code>fetchDataAsync(view)</code> which then performs a GET request via axios and dispatches based on what view was selected.</p>

<p>I'm still new with Redux, though, and I'm unsure of what I'm doing wrong here. I've seen an async action performed inside an action creator before...</p>

<p>Component connected with Redux:</p>

<pre><code>class ViewSelector extends Component {
  selectView(event) {
    this.props.fetchDataAsync(event.target.innerHTML);
  }

  render() {
    return (
      &lt;nav&gt;
        &lt;button onClick={this.selectView.bind(this)}&gt;VIEW ALL&lt;/button&gt;
        &lt;button onClick={this.selectView.bind(this)}&gt;VIEW LAST WEEK&lt;/button&gt;
        &lt;button onClick={this.selectView.bind(this)}&gt;VIEW LAST MONTH&lt;/button&gt;
      &lt;/nav&gt;
    );
  }
}

function mapStateToProps(state) {
  return {
    view: state.view
  };
}

export default connect(mapStateToProps, actions)(ViewSelector);
</code></pre>

<p>Action creator for dispatching based on <code>event.target.innerHTML</code>:</p>

<pre><code>export function fetchDataAsync(view) {
  return dispatch =&gt; {
    dispatch(fetchData());

    axios.get(DATA_URL)
    .then(res =&gt; {
      dispatch(fetchDataSuccess(res.data));
      if (view == 'VIEW LAST WEEK') {
        dispatch(lastWeekData(res.data));
      } else if (view == 'VIEW LAST MONTH') {
        dispatch(lastMonthData(res.data));
      }
    }).catch(err =&gt; {
      dispatch(fetchDataFailure(err));
    });
  };

}
</code></pre>

<p>Any advice is appreciated. Or if you believe there's a more effective way of capturing that user input and passing it to an action creator...I'd be curious to hear more!</p>