import React, { useRef } from 'react'
const scrollToRef = (ref) => window.scrollTo({ top: ref.current.offsetTop, behavior: "smooth" })
// General scroll to element function
const ScrollToSection = () => {
const sectionRef = useRef(null)
const executeSectionScroll = () => scrollToRef(myRef)
return (
<>
<div ref={sectionRef}>I wanna be seen</div>
<button onClick={executeSectionScroll}> Click to scroll </button>
</>
)
}