title: How to pass variables to a function reference?
body: <p>In react native when you have functions that need to run at render and must pass variables, most people suggest that one should use</p>
  
  <pre><code>onPress{() =&gt; this.functionName(variable)}
  </code></pre>
  
  <p>However when working with large lists and complex components you have to optimize your code. Creating a new function for every renderItem in a <code>flatList</code> reduces performance, sometimes hugely so depending on how many functions per renderItem you are creating. So the suggestion is to move from creating a function at render to using a function reference. Like this:</p>
  
  <pre><code>functionName = () =&gt; {
     //code
  }
  
  onPress={this.functionName}
  </code></pre>
  
  <p>However I haven't been able to figure out how to pass variables to the function with this method. </p>
  
  <p>If you do this:</p>
  
  <pre><code>onPress={this.functionName(variable}
  </code></pre>
  
  <p>It will just run the function instantly on component load.</p>
  
  <p>Any ideas?</p>