title: How to use ListItem onPress to toggle target state
body: <p>I am displaying this set of data in <code>FlatList</code>.</p>
  
  <pre><code>state = {
    data: [
      {key: 'DE', title: 'DE', selected: true},
      {key: 'FR', title: 'FR', selected: true},
      {key: 'GB', title: 'GB', selected: false},
      {key: 'US', title: 'US', selected: false},
      {key: 'GE', title: 'GE', selected: true},
      {key: 'JP', title: 'JP', selected: true},
    ],
  }
  </code></pre>
  
  <p>I want each item in the list to act like checkbox - pressing each item will toggle it's <code>selected</code> boolean.</p>
  
  <p>I'm rendering the FlatList like so:</p>
  
  <pre><code>  &lt;List containerStyle={{marginTop: 0}}&gt;
      &lt;FlatList
        data={this.state.data}
        keyExtractor={this._keyExtractor}
        renderItem={this._renderItem}
      /&gt;
    &lt;/List&gt;
  </code></pre>
  
  <p>And my <code>_renderItem</code> uses <code>ListItem</code> from <code>react-native-elements</code>. If <code>selected</code> is true, a tick icon is shown:</p>
  
  <pre><code>_renderItem = ({item, index}) =&gt; (
    &lt;ListItem
      title={item.title}
      avatar={getFlag(item.key)}
      onPress={this._onPressItem}
      rightIcon={{name: 'done'}}
      hideChevron={!item.selected}
    /&gt;
  )
  </code></pre>
  
  <hr>
  
  <p>So the problem is, how can I write my <code>_onPressItem</code> function to have it toggle the <code>selected</code> of pressed item?</p>
  
  <p>The demo code in <a href="https://facebook.github.io/react-native/docs/flatlist.html" rel="nofollow noreferrer">FlatList official docs</a> doesn't make sense to me:</p>
  
  <pre><code>_onPressItem = (id: string) =&gt; {
    // updater functions are preferred for transactional updates
    this.setState((state) =&gt; {
      // copy the map rather than modifying state.
      const selected = new Map(state.selected);
      selected.set(id, !selected.get(id)); // toggle
      return {selected};
    });
  }; 
  </code></pre>
  
  <p>When I run that, the onPress event will give me an event object, and accessing its <code>target</code> key will return me some unique IDs which I have no idea how to use:</p>
  
  <pre><code>_onPressItem = e =&gt; {
    console.log(e.target) // =&gt; a unique ID number
                         // How can I find the pressed data item?
  }; 
  </code></pre>