Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

enhance Controller props type #20

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,24 @@ export type ControllerProps<
TFieldName extends DeepPath<TFieldValues, TFieldName>,
TAs extends 'input' | 'select' | 'textarea'
> = Assign<
{
(
| {
as: TAs;
render?: undefined;
}
| {
as?: undefined;
render: (props: {
onChange: (...event: any[]) => void;
onBlur: () => void;
value: DeepPathValue<TFieldValues, TFieldName>;
}) => React.ReactElement;
}
) & {
name: TFieldName;
as?: TAs;
rules?: ValidationRules<DeepPathValue<TFieldValues, TFieldName>>;
onFocus?: () => void;
defaultValue?: DeepPathValue<TFieldValues, TFieldName>;
render?: (props: {
onChange: (...event: any[]) => void;
onBlur: () => void;
value: DeepPathValue<TFieldValues, TFieldName>;
}) => React.ReactElement;
},
JSX.IntrinsicElements[TAs]
>;
2 changes: 1 addition & 1 deletion src/useTypedController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const useTypedController = <
<Controller
name={formattedName as any}
control={controlRef.current}
{...rest}
{...(rest as any)}
/>
);
},
Expand Down