scroll to top in react

JavaScript
componentDidMount() {
  window.scrollTo(0, 0)
}useEffect(() => {
  window.scrollTo(0, 0)
}, [])
Source

Also in JavaScript: