grungnet/src/contexts/MapStageContext.tsx

17 lines
434 B
TypeScript
Raw Normal View History

import React, { useContext } from "react";
2020-05-21 02:46:50 -04:00
const MapStageContext = React.createContext({
mapStageRef: { current: null },
});
2021-06-03 01:31:18 -04:00
export const MapStageProvider: any = MapStageContext.Provider;
2020-05-21 02:46:50 -04:00
export function useMapStage() {
const context = useContext(MapStageContext);
if (context === undefined) {
throw new Error("useMapStage must be used within a MapStageProvider");
}
return context;
}
2020-05-21 02:46:50 -04:00
export default MapStageContext;