import React, { createContext, ReactNode, ComponentType, FunctionComponent } from 'react'; import * as model from './model'; // import { Props as WithRouterProps } from './Route'; export type State = { location: model.Location, locations?: model.Location[], match?: model.Match, viewport?: Object, }; type Value = { state: State, dispatch: ({}: { type: string, payload: Object }) => void, }; const initialState = { location: { pathname: '/', }, }; export const RouterContext = createContext({ state: initialState, dispatch: () => {}, }); export const RouterProvider = ({ locations, location, viewport, match, children, }: State & { children: ReactNode }) => { const state = { location, locations, viewport, match }; const dispatch = () => {}; return ( {children} ); }; type WithRouterProps = {}; // ??? export const withRouter =

(Component: ComponentType

): FunctionComponent

=> { return (props: P) => ( {(value) => { const { state } = value || {}; const { location, locations, viewport, match } = state || {}; return ( ); }} ); }