Created
April 22, 2017 01:06
-
-
Save silviopaganini/dc817ac9e09c62d7510481ad19747cb7 to your computer and use it in GitHub Desktop.
ScrollToTop
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'; | |
export default class ScrollToTop extends Component { | |
static propTypes = { | |
children: PropTypes.element, | |
} | |
static defaultProps = { | |
children: null, | |
} | |
componentDidMount() { | |
window.scrollTo(0, 0); | |
} | |
render() { | |
if (!this.props.children) return null; | |
return this.props.children; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment