title: React Native obtaining TextInput value in Redux
body: <p>I am currently learning how to use Redux after using vanilla React Native for some time. I am trying to understand how to store a <code>TextInput</code>'s value. Previously I would have simply stored the value in state. I have tried a few things including the code sample below.</p>
  
  <p>Currently, <code>todoInput.value</code> is undefined. I have also tried directly assigning the <code>value</code> prop of the <code>TextInput</code> to a variable defined with <code>let</code> but this also stays undefined.</p>
  
  <p>How can I alter the code so that the value of the <code>TextInput</code> is not undefined?</p>
  
  <pre><code>import React from 'react';
  import { View, Button, TextInput } from 'react-native';
  import { connect } from 'react-redux';
  import { addTodo } from '../actions';
  
  const addNewTodo = (dispatch, value) =&gt; {
    dispatch(addTodo(value));
  }
  
  const AddTodo = ({ dispatch }) =&gt; {
    let todoInput;
  
    return (
      &lt;View&gt;
        &lt;TextInput ref={inputRef =&gt; todoInput = inputRef} /&gt;
        &lt;Button title="Add Todo" onPress={() =&gt; addNewTodo(dispatch, todoInput.value)}&gt;&lt;/Button&gt;
      &lt;/View&gt;
    );
  };
  
  export default connect()(AddTodo);
  </code></pre>