mirror of
https://github.com/khairul169/db-backup-tool.git
synced 2025-04-28 16:49:34 +07:00
15 lines
442 B
TypeScript
15 lines
442 B
TypeScript
import { createContext, useContext } from "react";
|
|
import { FieldValues, UseFormReturn } from "react-hook-form";
|
|
|
|
const FormContext = createContext<UseFormReturn>(null!);
|
|
|
|
export const useFormContext = <T extends FieldValues>() => {
|
|
const context = useContext(FormContext);
|
|
if (!context) {
|
|
throw new Error("useFormContext must be used within a FormProvider");
|
|
}
|
|
return context as UseFormReturn<T>;
|
|
};
|
|
|
|
export default FormContext;
|