UNPKG

462 BTypeScriptView Raw
1import * as React from 'react';
2import * as MapboxGl from 'mapbox-gl';
3
4export const MapContext = React.createContext(undefined) as React.Context<
5 MapboxGl.Map | undefined
6>;
7
8// tslint:disable-next-line:no-any
9export function withMap(Component: React.ComponentClass<any>) {
10 return function MappedComponent<T>(props: T) {
11 return (
12 <MapContext.Consumer>
13 {map => <Component map={map} {...props} />}
14 </MapContext.Consumer>
15 );
16 };
17}