diff --git a/src/App.js b/src/App.js index 5218828..14de19c 100644 --- a/src/App.js +++ b/src/App.js @@ -2,7 +2,8 @@ import React, { Component } from 'react'; import { BrowserRouter as Router, Route, - Switch + Switch, + withRouter } from 'react-router-dom'; import hljs from 'highlight.js'; @@ -26,36 +27,38 @@ class App extends Component { render() { return ( -
-
+ +
+
- - - - - - - - - - { /* Page routes */ } - + + + + + + + + + + { /* Page routes */ } + - { /* Post routes */ } - - + { /* Post routes */ } + + - { /* 404 fallback */ } - - - - + { /* 404 fallback */ } + + + + - + -
+
+
); } @@ -69,6 +72,19 @@ class App extends Component { } } +class ScrollToTop extends Component { + componentDidUpdate(prevProps) { + if (this.props.location !== prevProps.location) { + window.scrollTo(0, 0); + } + } + + render() { + return this.props.children + } +} +ScrollToTop = withRouter(ScrollToTop); + // Dummy About page just for playing around with ReactRouter class About extends Component { render () {