Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RenderProps and RenderFunction types #11460

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 19 additions & 13 deletions src/types/controller.ts
Expand Up @@ -55,6 +55,23 @@
fieldState: ControllerFieldState;
};

export type RenderProps<
TFieldValues extends FieldValues = FieldValues,
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>

Check failure on line 60 in src/types/controller.ts

View workflow job for this annotation

GitHub Actions / build

Insert `,`
> = {
field: ControllerRenderProps<TFieldValues, TName>;

Check failure on line 62 in src/types/controller.ts

View workflow job for this annotation

GitHub Actions / build

Delete `··`
fieldState: ControllerFieldState;

Check failure on line 63 in src/types/controller.ts

View workflow job for this annotation

GitHub Actions / build

Delete `··`
formState: UseFormStateReturn<TFieldValues>;

Check failure on line 64 in src/types/controller.ts

View workflow job for this annotation

GitHub Actions / build

Delete `··`
}

Check failure on line 65 in src/types/controller.ts

View workflow job for this annotation

GitHub Actions / build

Insert `;`

export type RenderFunction<
TFieldValues extends FieldValues = FieldValues,
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>

Check failure on line 69 in src/types/controller.ts

View workflow job for this annotation

GitHub Actions / build

Insert `,`
> = ({
field,
fieldState,
formState

Check failure on line 73 in src/types/controller.ts

View workflow job for this annotation

GitHub Actions / build

Insert `,`
}: RenderProps<TFieldValues, TName>) => React.ReactElement;
/**
* Render function to provide the control for the field.
*
Expand All @@ -76,17 +93,6 @@
* />
* ```
*/
export type ControllerProps<
TFieldValues extends FieldValues = FieldValues,
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
> = {
render: ({
field,
fieldState,
formState,
}: {
field: ControllerRenderProps<TFieldValues, TName>;
fieldState: ControllerFieldState;
formState: UseFormStateReturn<TFieldValues>;
}) => React.ReactElement;
export type ControllerProps<TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = {

Check failure on line 96 in src/types/controller.ts

View workflow job for this annotation

GitHub Actions / build

Replace `TFieldValues·extends·FieldValues·=·FieldValues,·TName·extends·FieldPath<TFieldValues>·=·FieldPath<TFieldValues>` with `⏎··TFieldValues·extends·FieldValues·=·FieldValues,⏎··TName·extends·FieldPath<TFieldValues>·=·FieldPath<TFieldValues>,⏎`
render: RenderFunction<TFieldValues, TName>;

Check failure on line 97 in src/types/controller.ts

View workflow job for this annotation

GitHub Actions / build

Delete `··`
} & UseControllerProps<TFieldValues, TName>;