Sha256: 294aaa42e01f5b2e7b1876b72683dfd749454888cb09b7f4c1a0ba0f266e9172
Contents?: true
Size: 565 Bytes
Versions: 7
Compression:
Stored size: 565 Bytes
Contents
import * as PropTypes from 'prop-types'; import React from 'react'; import ReactRouterPropTypes from 'react-router-prop-types'; import { withRouter } from 'react-router-dom'; class ScrollToTop extends React.Component { static propTypes = { children: PropTypes.node.isRequired, location: ReactRouterPropTypes.location.isRequired }; componentDidUpdate(prevProps) { if (this.props.location !== prevProps.location) { window.scrollTo(0, 0); } } render() { return this.props.children; } } export default withRouter(ScrollToTop);
Version data entries
7 entries across 7 versions & 1 rubygems