mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-02-27 04:06:39 +00:00
24 lines
477 B
JavaScript
24 lines
477 B
JavaScript
import React from 'react';
|
|
import PropTypes from 'prop-types';
|
|
|
|
const ScrollToTop = ({ scrollTo }) => class ScrollToTop extends React.Component {
|
|
static propTypes = {
|
|
location: PropTypes.object,
|
|
children: PropTypes.node,
|
|
};
|
|
|
|
componentDidUpdate({ location: prevLocation }) {
|
|
const { location } = this.props;
|
|
|
|
if (location !== prevLocation) {
|
|
scrollTo(0, 0);
|
|
}
|
|
}
|
|
|
|
render() {
|
|
return this.props.children;
|
|
}
|
|
};
|
|
|
|
export default ScrollToTop;
|