From 3fe82a8652bfeeba84f7e40c3b98b231baa15b75 Mon Sep 17 00:00:00 2001 From: Tushar <47114550+tusharmaharana@users.noreply.github.com> Date: Mon, 8 Jan 2024 19:04:48 +0530 Subject: [PATCH] added onBlur, touched and extrainfo in Field component --- src/Field.tsx | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/Field.tsx b/src/Field.tsx index 0c6d967..ca00769 100644 --- a/src/Field.tsx +++ b/src/Field.tsx @@ -35,20 +35,21 @@ export const Field = (props: IField) => { validate, depFields, } = props; - const { fieldValue, setFieldValue, error } = useField({ - name, - ancestors, - defaultValue, - depFields, - validate: validate - ? validate - : (value) => { - if (required && !value) { - return 'Required'; - } - return null; - }, - }); + const { fieldValue, setFieldValue, error, onBlur, touched, extraInfo } = + useField({ + name, + ancestors, + defaultValue, + depFields, + validate: validate + ? validate + : (value) => { + if (required && !value) { + return 'Required'; + } + return null; + }, + }); const fieldProps = { value: fieldValue ?? '', @@ -57,7 +58,10 @@ export const Field = (props: IField) => { setFieldValue(val); handleChange?.(val); }, + onBlur, error, + touched, + extraInfo, }; if (typeof children === 'function') {