Added shared grid context and moved away from calling useContext directly
This commit is contained in:
@@ -1,8 +1,16 @@
|
||||
import React from "react";
|
||||
import React, { useContext } from "react";
|
||||
|
||||
const MapStageContext = React.createContext({
|
||||
mapStageRef: { current: null },
|
||||
});
|
||||
export const MapStageProvider = MapStageContext.Provider;
|
||||
|
||||
export function useMapStage() {
|
||||
const context = useContext(MapStageContext);
|
||||
if (context === undefined) {
|
||||
throw new Error("useMapStage must be used within a MapStageProvider");
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
export default MapStageContext;
|
||||
|
||||
Reference in New Issue
Block a user