From 1c88dc66219d7811870e61412e8dbbcb3f618d88 Mon Sep 17 00:00:00 2001 From: Samuel Rowe Date: Sat, 20 Aug 2022 12:23:55 +0530 Subject: [PATCH] feat: created `useSuperForm` hook --- services/frontend/src/hooks/index.ts | 1 + services/frontend/src/hooks/useSuperForm.ts | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 services/frontend/src/hooks/useSuperForm.ts diff --git a/services/frontend/src/hooks/index.ts b/services/frontend/src/hooks/index.ts index 78bf33e..016156e 100644 --- a/services/frontend/src/hooks/index.ts +++ b/services/frontend/src/hooks/index.ts @@ -1,3 +1,4 @@ export * from "./useTitle"; export * from "./useAccordionState"; export * from "./useTabContext"; +export * from "./useSuperForm"; diff --git a/services/frontend/src/hooks/useSuperForm.ts b/services/frontend/src/hooks/useSuperForm.ts new file mode 100644 index 0000000..bd2d206 --- /dev/null +++ b/services/frontend/src/hooks/useSuperForm.ts @@ -0,0 +1,12 @@ +import { useContext } from "react"; +import { SuperFormContext } from "../contexts"; +import { ISuperFormContext } from "../types"; + +export const useSuperForm = (): ISuperFormContext => { + const context = useContext(SuperFormContext); + if (!context) { + throw new Error("Cannot find super form context!"); + } + + return context; +};