title: ReactNative - Calling a function for height calculation during render does not always seem to invoke
body: <p>I was looking to calculate height dynamically of items in my <code>flatlist</code> based on the # of lines that my text will take up for each item. I got a function working perfectly that calculates the # of lines of text, however, when I call it from <code>render()</code>, it only seems to work 50-70% of the time - meaning to say not every instance of the list item uses my function. Sometimes it calls it, sometimes it just doesn't.</p>
  <p>This is my <code>listItem.js</code> class, which represents one item within my <code>flatlist</code>. I've included the function I am using as well.</p>
  <pre><code>getNumberOfLines(text) {
      const containerWidth = Dimensions.get('window').width * 0.8
      const fontConstant = 2.21  //times new roman
      const fontSize = LayoutHelpers.resultItemFontSize
      
      let cpl = Math.floor(containerWidth / (fontSize / fontConstant) );
      const words = text.split(' ');
      const elements = [];
      let line = '';
  
      while(words.length &gt; 0){
          if(line.length + words[0].length + 1 &lt;= cpl || line.length === 0 &amp;&amp; words[0].length + 1 &gt;= cpl){
              let word = words.splice(0,1);
              if(line.length === 0){
                  line = word;
              }else {
                  line = line + &quot; &quot; + word;
              }
              if(words.length === 0){
                  elements.push(line);
              }
          }
          else {
              elements.push(line);
              line = &quot;&quot;;
          }
      }
      return elements.length;
  }
  
      
    calculateHeight(text) {
   
      const numLines = this.getNumberOfLines(text)
      return (numLines * 16) + 40
  }
  
  render() {  
      return (
      &lt;View style={this.props.style}&gt;  
          &lt;View&gt;
               &lt;Text style={[styles.textStyle, {height: this.calculateHeight(this.summary)}]}&gt;
                    {this.summary()}
             &lt;/Text&gt; 
           &lt;/View&gt;         
        &lt;/View&gt;
      )
    }
  }
  </code></pre>
  <p>Is there an async-related issue where I can't calculate height like this?</p>
  <p>Thanks so much for any help/guidance!</p>