React-Native: Cannot access state values or any methods declared from renderRow
<p>I have a listview, whenever user clicks on an item, i want to do something with onPress (touchable highlight).</p>

<p>I tried defining function then calling them in onPress but they didnt work.</p>

<p>first i defined a function like this :</p>

<pre><code>constructor(props) {
        super(props);
        this.state = {
          dataSource: new ListView.DataSource({
            rowHasChanged: (row1, row2) =&gt; row1 !== row2,
          }),
          loaded: false,
        };
        this._dosome = this._dosome.bind(this);
    }

    _dosome(dd){
      console.log(dd);
    }
</code></pre>

<p>Then :</p>

<pre><code>render(){
  if (!this.state.loaded) {
      return this.renderLoadingView();
    }

    return (
      &lt;View style={{
        flex: 1
      }}&gt;
      &lt;ListView
        dataSource={this.state.dataSource}
        renderRow={this.renderRow}
        style={styles.listView}
      /&gt;
      &lt;/View&gt;
    );
  }

  renderRow(data) {

    var header = (
      &lt;View&gt;
          &lt;View style={styles.rowContainer}&gt;
            &lt;View  style={styles.textContainer}&gt;
              &lt;Text style={styles.title}&gt;{data.nid}&lt;/Text&gt;
              &lt;Text style={styles.description} numberOfLines={0}&gt;{data.title}&lt;/Text&gt;
            &lt;/View&gt;
          &lt;/View&gt;
          &lt;View style={styles.separator}&gt;&lt;/View&gt;
    &lt;/View&gt;
    );
///////////
    var cid = [];
    var content = [];
    for(let x=0; x &lt; Object.keys(data.course).length; x++){
      cid[x] = data.course[x].course_id;
      content.push(
        &lt;TouchableHighlight
        underlayColor='#e3e0d7'
        key={x}
        onPress={ this._dosome } //// **** PROBLEM HERE ****
        style={styles.child}
        &gt;
        &lt;Text style={styles.child}&gt;
        {data.course[x].title}
        &lt;/Text&gt;
        &lt;/TouchableHighlight&gt;
      );
    }
    console.log(cid);
    var clist = (
      &lt;View style={styles.rowContainer}&gt;
      {content}
      &lt;/View&gt;
    );
////////////
    return (
      &lt;Accordion
        header={header}
        content={clist}
        easing="easeOutCubic"
      /&gt;
    );
  }


  renderLoadingView() {
    return (
      &lt;View style={styles.loading}&gt;
        &lt;Text style={styles.loading}&gt;
          Loading Courses, please wait...
        &lt;/Text&gt;
      &lt;/View&gt;
    );
  }
}
</code></pre>

<p>But it didnt worked, error :</p>

<pre><code>TypeError: Cannot read property '_dosome' of null(…)
</code></pre>

<p>I tried calling it onPress like this :</p>

<pre><code>onPress={ this._dosome.bind(this) }
</code></pre>

<p>didn't help</p>

<pre><code>onPress={ ()=&gt; {this._dosome.bind(this)}}
</code></pre>

<p>didn't help</p>

<pre><code>onPress={ console.log(this.state.loaded)}
</code></pre>

<p>even i cannot even access props defined in constructor. it don't know what is "this" !</p>

<p>I tried to define the function other way like this :</p>

<pre><code>var _dosome = (dd) =&gt; {
      console.log(dd);
    };
</code></pre>

<p>I tried defining the _dosome before render, after render, inside render, inside renderRow, and after renderRow. all same results.</p>

<p>I did check lots of tutorials, lots of sample apps on rnplay, lots of threads in stackoverflow, lots of examples, but none of them worked for me.
any solutions/ideas?
Any help is highly appreciated. i'm struggling with this issue for 2 days now.
Thanks in Advance!</p>