import React, { Component } from 'react';
import { withRouter } from 'react-router';

class ScrollToTop extends Component {
  componentDidUpdate(prevProps) {
    const { location } = this.props;
    if (location !== prevProps.location) {
      window.scrollTo(0, 0);// eslint-disable-line no-undef
    }
  }

  render() {
    return null;
  }
}

export default withRouter(ScrollToTop);
