/* @flow */ import React, { Component, createContext } from 'react' import type { ComponentType } from 'react' export type Tracker = { push: (Array) => void, connectToHistory: Function } export const defaultTracker: Tracker = { push: console.log, // eslint-disable-line no-console connectToHistory: history => history } const TrackerContext = createContext(defaultTracker) export const TrackerProvider = TrackerContext.Provider export default function withTracker( WrappedComponent: ComponentType ) { class WithTracker extends Component<$Diff> { displayName = `withTracker(${WrappedComponent.displayName || ''})` render() { return ( {tracker => } ) } } return WithTracker }