title: How to access a row using FlatList keyExtractor in react-native
body: <p>Is there any way to access a row using key, set using keyExtractor in FlatList.</p>
  
  <p>I using FlatList inorder to populate by data, i need to get a row separately using it's key, inorder to update that row without re-render the entire view.</p>
  
  <p>on <strong>componentWillMount</strong> i populated datalist array using an api call.</p>
  
  <p>dummy array look this </p>
  
  <blockquote>
    <p>[{id:"Usr01",title:"Name1"},{id:"Usr02",title:"Name2"},...]</p>
  </blockquote>
  
  <p>while press on any row i get it's id, i need to access that row using it's key.</p>
  
  <blockquote>
    <p>let dataitem = this.state.datalist[id];</p>
  </blockquote>
  
  <p>while i console dataitem i get undefined</p>
  
  <p>i set id as the key in keyExtractor, is there any way to do the same.</p>
  
  <p>My code look like this</p>
  
  <p><strong>FlatListScreen.js</strong> </p>
  
  <pre><code>export default class FlatListScreen extends Component { 
  constructor(props)
  {
  super(props);
  this.state={
      datalist: [],
  }
  }
  
  componentWillMount() {
  ApiHandler.getlistitem('All').then(response =&gt;{
      this.setState({datalist: response});
  });
  }
  
  _keyExtractor = (item, index) =&gt; item.id;
  
  _onPressItem = (id) =&gt; {
  let dataitem = this.state.datalist[id];
  const { name } = dataitem
  const newPost = {
      ...dataitem,
      name: name+"01"
  }
  
  this.setState({
      datalist: {
          ...this.state.datalist,
          [id]: newPost
  }
  })
  };
  
  
  _renderItem ({ item }) {
      return (
      &lt;MyListItem
      id={item.id}
      onPressItem={this._onPressItem}
      title={item.title}
      /&gt;
      )
  } 
  
  
  render() {
  return ( 
  
  &lt;FlatList
      data={this.state.datalist}
      keyExtractor={this._keyExtractor}
      renderItem={this._renderItem}
  /&gt;
  
  
      );
  }
  
  }
  }
  </code></pre>
  
  <p><strong>MyListItem.js</strong></p>
  
  <pre><code>export default class MyListItem extends Component {
  constructor(props) {
      super(props)
      this.state = {
          title: '',
          id: ''
      }
  }
  
  componentWillMount() {
      const { title, id } = this.props
  
      this.setState({ title, id })
  }
  
  componentWillReceiveProps(nextProps) {
      const { title, id } = nextProps
  
      this.setState({ title, id })
  }
  
  
  shouldComponentUpdate(nextProps, nextState) {
      const { title} = nextState
      const { title: oldTitle } = this.state
      return title !== oldTitle
  }
  render() {
      return (
      &lt;View&gt;
      &lt;TouchableOpacity onPress={() =&gt;this.props.onPressItem({id:this.state.id})}&gt;
          &lt;View&gt;
          &lt;Text&gt;
              {this.props.title}
          &lt;/Text&gt;
          &lt;/View&gt;
      &lt;/TouchableOpacity&gt;
      &lt;/View&gt;
  
      );
  }
  }
  </code></pre>