Answers for "how to scroll smoothly in to the top in react js"

0

how to scroll smoothly in to the top in react js

function App() {
	const myRef = createRef()
    
    function scroll(ref) {
    	ref.current.scrollIntoView({ behavior: 'smooth' })
  	}
  
    return (
      <div className="App scrollToHere" ref={myRef}>
        Content...
        .....
        .....
        <button onClick={() => scroll(myRef)}>top</button>
      </div>
  )
}
Posted by: Guest on July-09-2021

Code answers related to "how to scroll smoothly in to the top in react js"

Browse Popular Code Answers by Language