diff --git a/src/contexts/EventsContext.tsx b/src/contexts/EventsContext.tsx
index be6958e..1f4066d 100644
--- a/src/contexts/EventsContext.tsx
+++ b/src/contexts/EventsContext.tsx
@@ -77,5 +77,12 @@ export const EventsProvider = ({
);
};
-export const useEventsContext = (): EventsContextValue =>
- useContext(EventsContext);
+export const useEventsContext = (): EventsContextValue => {
+ const context = useContext(EventsContext);
+ if (!context) {
+ throw new Error(
+ "useEventsContext must be used within a "
+ );
+ }
+ return context;
+};
diff --git a/src/contexts/ParamsContext.tsx b/src/contexts/ParamsContext.tsx
index 55db41e..aa89edd 100644
--- a/src/contexts/ParamsContext.tsx
+++ b/src/contexts/ParamsContext.tsx
@@ -36,5 +36,12 @@ export const ParamsProvider = ({
);
};
-export const useParamsContext = (): ParamsContextValue =>
- useContext(ParamsContext);
+export const useParamsContext = (): ParamsContextValue => {
+ const context = useContext(ParamsContext);
+ if (!context) {
+ throw new Error(
+ "useParamsContext must be used within a "
+ );
+ }
+ return context;
+};