import React , { ComponentType } from 'react' ; import { Router } from 'router5' ; import { routerContext } from '../context' ; function withRouter < P > ( BaseComponent ) { return function WithRouter ( props ) { return ( < routerContext . Consumer > { router => < BaseComponent { ... props } router = { router } / > } < /routerContext.Consumer>); } ; } export default withRouter ;