title: React Native Updating an Array of JSON objects onChangeText, index undefined
body: <p>I've got a useState variable that has an array of JSON objects, and I'm trying to get the text fields to dynamically render and update with onChangeText, but I'm having a bit of an issue with this.</p>
  <p>When I add console.log(index) to updateHashtags, it says it is undefined, and I can't understand what I'm doing wrong or can do to make this work. In theory, the index should be a static number for each text field. So the first text field would have hashtags[0] as its value and use '0' as the index for updating the state of hashtags.</p>
  <p>When I use:
  <code>console.log('index',index);</code>
  inside of <code>updateHashtags</code>, I get:
  <code>index undefined</code></p>
  <p>Here's the code:</p>
  <pre><code>  const updateHashtags = (text, index) =&gt; {
      let ht = hashtags;
      ht[index].name = text;
      setHashtags(ht);
    }
  
    const hashtagElement = (
      &lt;&gt;
      &lt;Text style={styles.plainText} &gt;Set Your Values:&lt;/Text&gt;
      &lt;Text style={styles.instructionsText} &gt;This is what other users use to search for you.&lt;/Text&gt;
      {hashtags.map((e,index) =&gt; 
      &lt;TextInput 
        placeholder='value'
        key={e.name + index}
        value={hashtags[index].name}
        onChangeText={(text,index) =&gt; updateHashtags(text,index)}
        style={styles.textInput}  
      /&gt;
      )}
      &lt;TouchableOpacity 
        onPress={() =&gt; {
          let ht = hashtags;
          let newht = {
              name: '',
              weight: 0,
          };
          ht[ht.length] = newht;
          setHashtags(ht);
        }}
      &gt;
        &lt;Ionicons 
          name=&quot;add-circle-outline&quot;
          size={40}
          color={'black'}
        /&gt;
      &lt;/TouchableOpacity&gt;
      &lt;/&gt;
    );
  </code></pre>