What is mapDispatchToProps?
<p>I was reading the documentation for the Redux library and it has this example:</p>
<blockquote>
<p>In addition to reading the state, container components can dispatch actions. In a similar fashion, you can define a function called <code>mapDispatchToProps()</code> that receives the <code>dispatch()</code> method and returns callback props that you want to inject into the presentational component.</p>
</blockquote>
<p>This actually makes no sense. Why do you need <code>mapDispatchToProps</code> when you already have <code>mapStateToProps</code>?</p>
<p>They also provide this handy code sample:</p>
<pre><code>const mapDispatchToProps = (dispatch) =&gt; {
  return {
    onTodoClick: (id) =&gt; {
      dispatch(toggleTodo(id))
    }
  }
}
</code></pre>
<p>What is this function and why it is useful?</p>