react scroll component to top code example
Example 1: scroll to top in react
componentDidMount() {
window.scrollTo(0, 0)
}
Example 2: react scroll to top
const scrollTop = () =>{ window.scrollTo({top: 0, behavior: 'smooth'});};
componentDidMount() {
window.scrollTo(0, 0)
}
const scrollTop = () =>{ window.scrollTo({top: 0, behavior: 'smooth'});};