mirror of
https://github.com/visgl/react-map-gl.git
synced 2026-01-18 15:54:22 +00:00
Fix useMap return type (#2262)
This commit is contained in:
parent
63c15208c9
commit
a212f1358e
@ -52,10 +52,12 @@ export const MapProvider: React.FC<{children?: React.ReactNode}> = props => {
|
||||
);
|
||||
};
|
||||
|
||||
export function useMap<MapT extends MapInstance>(): {
|
||||
export type MapCollection<MapT extends MapInstance> = {
|
||||
[id: string]: MapRef<MapT> | undefined;
|
||||
current?: MapRef<MapT>;
|
||||
} {
|
||||
};
|
||||
|
||||
export function useMap<MapT extends MapInstance>(): MapCollection<MapT> {
|
||||
const maps = useContext(MountedMapsContext)?.maps;
|
||||
const currentMap = useContext(MapContext);
|
||||
|
||||
@ -63,5 +65,5 @@ export function useMap<MapT extends MapInstance>(): {
|
||||
return {...maps, current: currentMap?.map};
|
||||
}, [maps, currentMap]);
|
||||
|
||||
return mapsWithCurrent as {current?: MapRef<MapT>; [id: string]: MapRef<MapT> | undefined};
|
||||
return mapsWithCurrent as MapCollection<MapT>;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user