react-accessible-form
Version:
React Accessible Form handles makes layout and accessibility easy when writing forms.
13 lines (9 loc) • 396 B
text/typescript
import { useContext } from "react";
import { FormGroupContext, FormGroupContextValue } from "./FormGroupContext";
export const useGroupContext = (elemName = "useGroupContext"): FormGroupContextValue => {
const groupContext = useContext(FormGroupContext);
if (!groupContext) {
throw new Error(`${elemName} must be used inside of a FormGroup`);
}
return groupContext;
};