Analytics (#582)
* gtm > ga * Record pageviews in SPA * Remove home-rolled tracking in favor of autotrack * cleanup
This commit is contained in:
18
app/components/ScrollToTop.js
Normal file
18
app/components/ScrollToTop.js
Normal file
@@ -0,0 +1,18 @@
|
||||
// @flow
|
||||
// based on: https://reacttraining.com/react-router/web/guides/scroll-restoration
|
||||
import { Component } from 'react';
|
||||
import { withRouter } from 'react-router-dom';
|
||||
|
||||
class ScrollToTop extends Component {
|
||||
componentDidUpdate(prevProps) {
|
||||
if (this.props.location !== prevProps.location) {
|
||||
window.scrollTo(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
export default withRouter(ScrollToTop);
|
||||
Reference in New Issue
Block a user