Created
February 18, 2018 01:41
-
-
Save gijun19/2c988dda38b9d37be64841453210c4d1 to your computer and use it in GitHub Desktop.
React ScrollToTop Component.
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
// @flow | |
import { Component } from 'react'; | |
import { withRouter } from 'react-router-dom'; | |
class ScrollToTop extends Component { | |
componentDidMount() { | |
window.scrollTo(0, 0); | |
} | |
render() { | |
return this.props.children ? this.props.children : null; | |
} | |
} | |
export default withRouter(ScrollToTop); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment