Answers for "smooth scroll to top of page react"

2

scroll to top in react

useEffect(() => {
  window.scrollTo(0, 0)
}, [])
Posted by: Guest on August-28-2020
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
0

smooth scroll react

$ npm install react-scroll
Posted by: Guest on August-14-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language