Closes #103 - Scroll to top on nav

This commit is contained in:
Tom Moor
2017-07-02 22:16:48 -07:00
parent 8dfbd1cc59
commit 5fa9029caa
3 changed files with 58 additions and 34 deletions

View 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';
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);

View File

@@ -0,0 +1,3 @@
// @flow
import ScrollToTop from './ScrollToTop';
export default ScrollToTop;