title: React: passing parameters to a function in map
body: <p>I am building a component that shows array of users in React using MaterialDesign's Table.</p>
  
  <p><a href="https://i.stack.imgur.com/ZOpIw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZOpIw.png" alt="Users Table"></a>
   Each row is generated by a map function:</p>
  
  <pre><code>let actions = this.props.rowButtons;
  ...
  {this.props.tableData.map( (val, index) =&gt; (
                         &lt;TableRow key={index}&gt;
                           &lt;TableRowColumn &gt;{index}&lt;/TableRowColumn&gt;
                           &lt;TableRowColumn &gt;{val.firstName}&lt;/TableRowColumn&gt;
                           &lt;TableRowColumn &gt;{val.lastName}&lt;/TableRowColumn&gt;
                           &lt;TableRowColumn &gt;{val.email}&lt;/TableRowColumn&gt;
                           &lt;TableRowColumn &gt;
                              &lt;ActionButtons actions={actions}/&gt;
                           &lt;/TableRowColumn&gt;
                         &lt;/TableRow&gt;
  ))}
  </code></pre>
  
  <p><code>&lt;ActionButtons&gt;</code> component creates one or many buttons, and as an argument takes array of objects like <code>[{type: string, onClick: function}, {type: string, onClick: function}, ... ]</code> (one button for each object in array);
  Parent component is sending such an array in <strong>this.props.rowButtons</strong>. </p>
  
  <p>I want to pass <strong>val</strong>  as an argument to each onClick function to have something like</p>
  
  <pre><code>actions = [{type: "personButton", onClick: onClick(val)}, {type: '', onclick: someOtherfunction(val)}]; 
  </code></pre>