feat: action context & hook

This commit is contained in:
karishmas6
2024-07-24 19:30:22 +05:30
parent 8716c8fc16
commit 5576aa26b0

View File

@@ -8,3 +8,13 @@ interface ActionContextType {
resetActions: () => void;
}
const ActionContext = createContext<ActionContextType | undefined>(undefined);
export const useActionContext = (): ActionContextType => {
const context = useContext(ActionContext);
if (context === undefined) {
throw new Error('useActionContext must be used within an ActionProvider');
}
return context;
};