feat: Introduce InputCreator
This commit is contained in:
20
packages/web/src/components/Form/index.tsx
Normal file
20
packages/web/src/components/Form/index.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import React from 'react';
|
||||
import { FormProvider, useForm, FieldValues, SubmitHandler, UseFormReturn } from "react-hook-form";
|
||||
|
||||
type FormProps = {
|
||||
children: React.ReactNode;
|
||||
onSubmit: SubmitHandler<FieldValues>;
|
||||
}
|
||||
|
||||
export default function Form(props: FormProps) {
|
||||
const { children, onSubmit, ...formProps } = props;
|
||||
const methods: UseFormReturn = useForm();
|
||||
|
||||
return (
|
||||
<FormProvider {...methods}>
|
||||
<form onSubmit={methods.handleSubmit(onSubmit)} {...formProps}>
|
||||
{children}
|
||||
</form>
|
||||
</FormProvider>
|
||||
);
|
||||
};
|
Reference in New Issue
Block a user