Created
May 30, 2018 12:24
-
-
Save manjunatha-d/4b6237cfc8dbce68aa750fc295b076a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from 'react'; | |
import PropTypes from 'prop-types'; | |
class ScrollToTopOnMount extends Component { | |
componentDidMount() { | |
const { top = 0, left = 0, behavior = 'smooth' } = this.props; | |
window.scrollTo({ | |
top, | |
left, | |
behavior | |
}); | |
} | |
render() { | |
return null; | |
} | |
} | |
ScrollToTopOnMount.propTypes = { | |
top: PropTypes.number, | |
left: PropTypes.number, | |
behavior: PropTypes.string | |
}; | |
export default ScrollToTopOnMount; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment