import { FieldValues, useFormContext, UseFormReturn } from "react-hook-form";

interface Props {
  render: ({ ...methods }: UseFormReturn<FieldValues, any>) => JSX.Element;
}

/**
 * Wrap a component to pass the form context to it.
 */
export const ConnectForm = ({ render }: Props) => {
  const methods = useFormContext();

  return render({ ...methods });
};
