You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

23 lines
702 B

import { createContext, useContext } from 'react';
export const CONTEXT_VERSION = 1;
export function createLeafletContext(map) {
return Object.freeze({
__version: CONTEXT_VERSION,
map
});
}
export function extendContext(source, extra) {
return Object.freeze({
...source,
...extra
});
}
export const LeafletContext = createContext(null);
export const LeafletProvider = LeafletContext.Provider;
export function useLeafletContext() {
const context = useContext(LeafletContext);
if (context == null) {
throw new Error('No context provided: useLeafletContext() can only be used in a descendant of <MapContainer>');
}
return context;
}