1 | import * as React from 'react';
|
2 | import * as MapboxGl from 'mapbox-gl';
|
3 |
|
4 | export const MapContext = React.createContext(undefined) as React.Context<
|
5 | MapboxGl.Map | undefined
|
6 | >;
|
7 |
|
8 | // tslint:disable-next-line:no-any
|
9 | export 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 | }
|