From 5576aa26b032c62f07f4d429ffec866269c9a9b8 Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Wed, 24 Jul 2024 19:30:22 +0530 Subject: [PATCH] feat: action context & hook --- src/context/browserActions.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/context/browserActions.tsx b/src/context/browserActions.tsx index 46d2d936..7afc5337 100644 --- a/src/context/browserActions.tsx +++ b/src/context/browserActions.tsx @@ -8,3 +8,13 @@ interface ActionContextType { resetActions: () => void; } +const ActionContext = createContext(undefined); + +export const useActionContext = (): ActionContextType => { + const context = useContext(ActionContext); + if (context === undefined) { + throw new Error('useActionContext must be used within an ActionProvider'); + } + return context; +}; +