import { Location } from 'history' ; import { Component } from 'react' ; interface Props { location : Location ; } export class ScrollToTopOnPathChange extends Component < Props > { public componentDidUpdate ( prevProps ) { if ( this . props . location . pathname !== prevProps . location . pathname ) { window . scrollTo ( 0 , 0 ) ; } } public render ( ) { return null ; } }