grungnet/src/contexts/MapInteractionContext.js

25 lines
604 B
JavaScript
Raw Normal View History

import React, { useContext } from "react";
const MapInteractionContext = React.createContext({
2020-05-21 02:46:50 -04:00
stageScale: 1,
stageWidth: 1,
stageHeight: 1,
setPreventMapInteraction: () => {},
mapWidth: 1,
mapHeight: 1,
interactionEmitter: null,
});
export const MapInteractionProvider = MapInteractionContext.Provider;
export function useMapInteraction() {
const context = useContext(MapInteractionContext);
if (context === undefined) {
throw new Error(
"useMapInteraction must be used within a MapInteractionProvider"
);
}
return context;
}
export default MapInteractionContext;