Created
September 4, 2017 05:46
-
-
Save itsdouges/cbf11c28b2f583dd18380313f9c6ea82 to your computer and use it in GitHub Desktop.
HOC to scroll to to top of the page when mounted
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'; | |
const withScroll = (WrappedComponent: React.ComponentType<*>) => class ScrollTopOnMount extends Component<void> { | |
componentDidMount () { | |
window.scrollTo(0, 0); | |
} | |
render () { | |
return <WrappedComponent {...this.props} />; | |
} | |
}; | |
export default withScroll; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment