title: react-native (js) : generalise a function
body: <p>I have two functions which I would like to condense into one (with another argument). They are called like so:</p>
  
  <pre><code>&lt;ListView
      automaticallyAdjustContentInsets={false}
      dataSource={this.state.dataSource_proj}
      renderRow={this.renderProjRow.bind(this)}/&gt;
  &lt;ListView
      automaticallyAdjustContentInsets={false}
      dataSource={this.state.dataSource_map}
      renderRow={this.renderMapRow.bind(this)}/&gt;
  </code></pre>
  
  <p>And the functions are:</p>
  
  <pre><code>renderProjRow(rowData, sectionID, rowID) {
      return (
          &lt;TouchableHighlight onPress={() =&gt; this.rowProjPressed(rowData.project_name)}
              underlayColor='#dddddd'&gt;
              &lt;View&gt;
                  &lt;View style={styles.rowContainer}&gt;
                      &lt;Image source={{uri: 'Letter-' + rowData.project_name.substr(0,1).toUpperCase()}} 
                          style={styles.thumb}/&gt;
                      &lt;View style={styles.textContainer}&gt;
                          &lt;Text style={styles.title}
                              numberOfLines={1}&gt;{rowData.project_name}&lt;/Text&gt;
                      &lt;/View&gt;
                  &lt;/View&gt;
                  &lt;View Style={styles.separator}/&gt;
              &lt;/View&gt;
          &lt;/TouchableHighlight&gt;
      );
  }
  
  renderMapRow(rowData, sectionID, rowID) {
      return (
          &lt;TouchableHighlight onPress={() =&gt; this.rowMapPressed(rowData)}
              underlayColor='#dddddd'&gt;
              &lt;View&gt;
                  &lt;View style={styles.rowContainer}&gt;
                      &lt;Image source={{uri: 'Letter-' + rowData.map_name.substr(0,1).toUpperCase()}} 
                          style={styles.thumb}/&gt;
                      &lt;View style={styles.textContainer}&gt;
                          &lt;Text style={styles.title}
                              numberOfLines={1}&gt;{rowData.map_name}&lt;/Text&gt;
                      &lt;/View&gt;
                  &lt;/View&gt;
                  &lt;View Style={styles.separator}/&gt;
              &lt;/View&gt;
          &lt;/TouchableHighlight&gt;
          );
  }
  </code></pre>
  
  <p>I would like to just have one function: <code>renderRow</code>, which takes <code>rowData.project_name</code> if the data-source is <code>dataSource_proj</code> and <code>rowData.map_name</code> if the data-source is <code>dataSource_map</code>.</p>
  
  <p>However, aside from using eval ... I'm not sure how to implement this in a proper way.</p>