title: React Native. Best way for scroll to element inside ScrollView
body: <p>I have scroll view with some component.</p>
  
  <pre><code>&lt;ScrollView ref={ref =&gt; this.contentRef = ref}&gt;
      &lt;SomeComponent ref={ref =&gt; this.targetRef = ref}
  &lt;/ScrollView&gt;
  </code></pre>
  
  <p>What is the best way for scroll to SomeComponent but limit to ScrollView height?</p>
  
  <p>My try:</p>
  
  <pre><code>if (this.contentRef &amp;&amp; this.targetRef) {
      const UIManager = NativeModules.UIManager;
      UIManager.measure(findNodeHandle(this.contentRef), (contentX, contentY, contentW, contentH) =&gt; {
      UIManager.measure(findNodeHandle(this.targetRef), (activeStepX, activeStepY) =&gt; {
          const h = Dimensions.get('window').height;
          if (activeStepY &gt; contentH / 2) {
          this.contentRef.scrollTo({ x: 0, y: h, animated });
          } else {
              this.contentRef.scrollTo({ x: 0, y: contentH, animated });
          };
      });
      });
  };
  </code></pre>
  
  <p>But if target very close to screen bottom, I have empty space on bottom (sorry, I need to hide any information).</p>
  
  <p><a href="https://i.stack.imgur.com/DJFIL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DJFIL.png" alt="enter image description here"></a></p>
  
  <p>But should to look like</p>
  
  <p><a href="https://i.stack.imgur.com/Rp95f.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Rp95f.png" alt="enter image description here"></a></p>