feat: make substeps updatable
This commit is contained in:

committed by
Ömer Faruk Aydın

parent
6c0ba197c6
commit
91a1c8b793
@@ -1,14 +1,20 @@
|
||||
import * as React from 'react';
|
||||
import { FormProvider, useForm, FieldValues, SubmitHandler, UseFormReturn } from 'react-hook-form';
|
||||
import type { UseFormProps } from 'react-hook-form';
|
||||
|
||||
type FormProps = {
|
||||
children: React.ReactNode;
|
||||
onSubmit: SubmitHandler<FieldValues>;
|
||||
defaultValues?: UseFormProps['defaultValues'];
|
||||
onSubmit?: SubmitHandler<FieldValues>;
|
||||
}
|
||||
|
||||
const noop = () => null;
|
||||
|
||||
export default function Form(props: FormProps): React.ReactElement {
|
||||
const { children, onSubmit, ...formProps } = props;
|
||||
const methods: UseFormReturn = useForm();
|
||||
const { children, onSubmit = noop, defaultValues, ...formProps } = props;
|
||||
const methods: UseFormReturn = useForm({
|
||||
defaultValues,
|
||||
});
|
||||
|
||||
return (
|
||||
<FormProvider {...methods}>
|
||||
|
Reference in New Issue
Block a user