title: React-Native: Get dimensions of props.children
body: <p>I am trying to build a Library for React-Native and I have an unusual  requirement. I don't know If its possible or not.</p>
  
  <p>I have to build a wrapper component, Lets say</p>
  
  <pre><code>&lt;Container showContent={true}&gt;
    &lt;Text&gt;hello&lt;/Text&gt;
  &lt;/Container&gt;
  </code></pre>
  
  <p>And inside Container, It would be like this</p>
  
  <pre><code>render() {
    &lt;View&gt;
      {this.props.children}
    &lt;/View&gt;
  }
  </code></pre>
  
  <p>The problem is, this would be a conditional render. I know I can get the Dimensions of children by just using the parent <code>&lt;View&gt;</code>component inside the container component.</p>
  
  <p>But I can't, Why? Because I want to measure it without rendering. 
  It would be like </p>
  
  <pre><code>render() {
    if(this.props.showContent) {
      return this.props.children;
    }
    return &lt;SomeOtherView /&gt;
  }
  </code></pre>
  
  <p>And initially It would be <code>SomeOtherView</code> and during that phase, I need the height and width of the children components.
  I don't want to pass methods and all, as I am building a library. So I want an elegant way. I just want the user to use my component like it is included in first code snippet and inside component I should get the height and width of children even without rendering it.</p>
  
  <p>I don't know if it's possible or not. 
  I tried to see all the methods provided by <code>props.children</code>, but can't find any which I can use.</p>