Check out example codes for "scroll to top smooth safari". It will help you in understanding the concepts better.

Code Example 1

<!--Example of a button to scroll to top, Remember to use the same id on both 
	the button and the function -->
  <button id='myBtn' >
    Click me to go to top!

<!-- When the user clicks on the button, scroll to the top of the document-->
    document.querySelector('#myBtn').addEventListener('click', function(e) {
      document.querySelector('body').scrollIntoView({ behavior: 'smooth' });
<!--To make it work you need to add the link to the file.-->
  <script src="smoothscroll.js"></script>

<!--I leave you the link to the file on the side:  -->

Learn ReactJs, React Native from