diff --git a/src/index.tsx b/src/index.tsx index bccb2dd..b6c8b66 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -63,8 +63,8 @@ const RHFInput = ({ }; const eventWrapper = (event: EventFunction, eventName: string) => { - return (...arg: any) => { - const data = commonTask(event(arg)); + return async (...arg: any) => { + const data = commonTask(await event(arg)); setValue( name, data, diff --git a/src/types.ts b/src/types.ts index c47006d..090c9e5 100644 --- a/src/types.ts +++ b/src/types.ts @@ -21,13 +21,15 @@ export type ValidationOptions = Partial<{ | { value: Validate | Record; message: string }; }>; -export type EventFunction = ( - args: any, -) => { +type EventFunctionResult = { value?: any; checked?: boolean; }; +export type EventFunction = ( + args: any, +) => EventFunctionResult | Promise; + export type Props = { children?: React.ReactNode; innerProps?: any;