got to a good point with sighting modal, want to do cleanup
This commit is contained in:
21
src/context/AlertHitContext.ts
Normal file
21
src/context/AlertHitContext.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { createContext, useContext } from "react";
|
||||
import type { AlertState, AlertPayload, ActionType } from "../types/types";
|
||||
|
||||
type AlertHitContextValueType = {
|
||||
state: AlertState;
|
||||
action: AlertPayload;
|
||||
disptach: (action: ActionType) => AlertState;
|
||||
};
|
||||
|
||||
export const AlertHitContext = createContext<
|
||||
AlertHitContextValueType | undefined
|
||||
>(undefined);
|
||||
|
||||
export const useAlertHitContext = () => {
|
||||
const ctx = useContext(AlertHitContext);
|
||||
if (!ctx)
|
||||
throw new Error("useAlertHitContext must be used within <AlertHitContext>");
|
||||
return ctx;
|
||||
};
|
||||
|
||||
export default AlertHitContext;
|
||||
Reference in New Issue
Block a user