Im trying to use scrollIntoView to scroll inside of a parent div but I get this following error 'Property 'scrollIntoView' does not exist on type 'HTMLCollectionOf'.' I have a button that should scroll to the top of the div im currently selecting. Here is my following code :
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js">
const scrollToTop = () => {
const element = document.getElementsByClassName("vendorCard");
element.scrollIntoView()
}
<button
onClick={scrollToTop}
className="hidden"
id="resetScroll"
style={{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
padding: '10px',
border: 'none !important'
}}
type="button"
>
<ArrowUpwardIcon />
<p style={{ fontSize: '0.7em', fontWeight: '200' }}>BACK</p>
</button>
</script>