Skip to content

Commit 513986d

Browse files
authored
fix(form-field-errors): useFormState instead of useFormContext (#635)
1 parent e6e3a93 commit 513986d

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/components/form/form-field-error.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
FieldPath,
88
FieldValues,
99
get,
10-
useFormContext,
10+
useFormState,
1111
} from 'react-hook-form';
1212

1313
import { cn } from '@/lib/tailwind/utils';
@@ -43,9 +43,7 @@ export const FormFieldError = <
4343
TFieldValues,
4444
TName
4545
> | null>(FormFieldControllerContext as ExplicitAny);
46-
const {
47-
formState: { errors },
48-
} = useFormContext<TFieldValues, TName>();
46+
const { errors } = useFormState<TFieldValues>();
4947
const control = 'control' in props ? props.control : controllerCtx?.control;
5048
const name = 'name' in props ? props.name : controllerCtx?.name;
5149

0 commit comments

Comments
 (0)