mirror of
https://github.com/sstent/aicyclingcoach-go.git
synced 2026-01-27 01:22:18 +00:00
sync
This commit is contained in:
34
node_modules/react-leaflet/lib/hooks.js
generated
vendored
Normal file
34
node_modules/react-leaflet/lib/hooks.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import { useLeafletContext } from '@react-leaflet/core';
|
||||
import { useEffect } from 'react';
|
||||
export function useMap() {
|
||||
return useLeafletContext().map;
|
||||
}
|
||||
export function useMapEvent(type, handler) {
|
||||
const map = useMap();
|
||||
useEffect(function addMapEventHandler() {
|
||||
// @ts-ignore event type
|
||||
map.on(type, handler);
|
||||
return function removeMapEventHandler() {
|
||||
// @ts-ignore event type
|
||||
map.off(type, handler);
|
||||
};
|
||||
}, [
|
||||
map,
|
||||
type,
|
||||
handler
|
||||
]);
|
||||
return map;
|
||||
}
|
||||
export function useMapEvents(handlers) {
|
||||
const map = useMap();
|
||||
useEffect(function addMapEventHandlers() {
|
||||
map.on(handlers);
|
||||
return function removeMapEventHandlers() {
|
||||
map.off(handlers);
|
||||
};
|
||||
}, [
|
||||
map,
|
||||
handlers
|
||||
]);
|
||||
return map;
|
||||
}
|
||||
Reference in New Issue
Block a user