title: how to get access method dispatch() into component of class
body: <p>Good afternoon! I started dealing with <code>react-redux</code> and got stuck at one point. I don't know how to access the <code>dispatch</code> method inside the component itself. The thing is, I'm trying to get data from form fields. In the <code>mapDispatchToProps</code> method, I can't get <code>refs</code>. How to do this correctly please tell me?</p>
  
  <p>For example:
  index.js</p>
  
  <pre><code>import React from 'react'
  import ReactDOM from 'react-dom'
  
  import { Provider } from 'react-redux'
  import store from './store'
  
  import App from './App'
  
  const rootElement = document.getElementById('root')
  ReactDOM.render(
    &lt;Provider store={store}&gt;
      &lt;App /&gt;
    &lt;/Provider&gt;,
    rootElement
  )
  </code></pre>
  
  <p>The code was typed here, could be typoed in the syntax...
  App.js</p>
  
  <pre><code>// imports ...
  class App extends React.Component {
    constructor(props) {
      super(props);
      this.title = React.createRef();
      this.message = React.createRef();
    }
  
    // Idea 1
    onSubmitHandler_1 = e =&gt; {
      e.preventDefault();
      // how get store.dispatch({type:"UPDATE", this.title.current.value, this.message.current.value});
    };
  
    render() {
      return (
        &lt;form onSubmit={this.props.onSubmitHandler_1 OR this.onSubmitHandler_2}&gt;
          &lt;input type="text" ref={this.title} name="title" /&gt;
          &lt;input type="password" ref={this.message} name="password" /&gt;
          &lt;button&gt;Send&lt;/button&gt;
        &lt;/form&gt;
      );
    }
  }
  
  const mapDispatchToProps = (state, ownProps) =&gt; {
    return {};
  };
  
  // Idea 1;
  const mapDispacthTOProps = (dispatch, ownProps) =&gt; {
    return {
      onSubmitHandler_2: e =&gt; {
        e.preventDefault();
        // oh... no!!! bad idea...
        // let inputTitle = e.target.querySelector('[name="title"]');
        // let inputTitle = e.target.querySelector('[name="password"]')
        dispatch({ type: "UPDATE" }); //... ???? refs
        // how get access to fields or refs??
      }
    };
  };
  
  export default connect(mapDispatchToProps, mapDispacthTOProps)(App);
  
  </code></pre>