I'm trying to figure out how to scroll to the element after page reloads. I'm trying to ref the element and scroll to it after page reloads.
My current example will just scroll to the end of the page
const transactionRef = useRef(null)
const scrollToElemet = () => {
transactionRef.current.scrollIntoView({ block: 'end', behavior: 'smooth' });
}
useEffect(scrollToElemet)
return (
<div ref={transactionRef}></div>
)
How can I calculate the position of the element and scroll to it on page reload? Thanks