Remove unused code.

This commit is contained in:
Sacha Weatherstone
2022-08-20 18:48:41 +09:30
parent db8c8f916b
commit 170f2e62cf
8 changed files with 81 additions and 125 deletions
-32
View File
@@ -1,32 +0,0 @@
import type React from "react";
import { useEffect, useState } from "react";
import { Map, MapOptions } from "maplibre-gl";
export interface useMapboxProps {
ref: React.RefObject<HTMLDivElement>;
style: string;
options?: Partial<MapOptions>;
}
export function useCreateMapbox({
ref,
style,
options,
}: useMapboxProps): Map | undefined {
const [mapInstance, setMapInstance] = useState<Map>();
useEffect(() => {
const container = ref.current as HTMLDivElement;
if (mapInstance || !container) {
return;
}
const map = new Map({
container,
style,
...options,
});
setMapInstance(map);
}, []);
return mapInstance;
}
-14
View File
@@ -1,14 +0,0 @@
import { createContext, useContext } from "react";
import type { Map } from "maplibre-gl";
export interface MapContextValue {
ref: React.Ref<HTMLDivElement>;
map?: Map;
}
export const MapContext = createContext<MapContextValue>({} as MapContextValue);
export const useMap = (): MapContextValue => {
return useContext(MapContext);
};