import {History, Location} from 'history' import {withRouter, match as Match} from 'react-router' import React from 'react' export interface WithHistoryProps { history: History location: Location match: Match } export function withHistory( Component: React.ComponentType, ) { class HistoryProvider extends React.PureComponent { render() { const {history, children} = this.props return ( {children} ) } } // stop TypeScript from complaining that we're using a private variable const HP: React.ComponentType = HistoryProvider return withRouter(HP) }