Skip to content

Change all uses of RHF <Controller> to useController #2102

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

Merged
merged 1 commit into from
Mar 27, 2024

Conversation

david-crespo
Copy link
Collaborator

TIL <Controller> is just useController in a trenchcoat. Remove the trenchcoat. Render props are so 2016.

const Controller = <
  TFieldValues extends FieldValues = FieldValues,
  TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
>(
  props: ControllerProps<TFieldValues, TName>,
) => props.render(useController<TFieldValues, TName>(props));

https://github.com/react-hook-form/react-hook-form/blob/306627e385738e322cad8dff9e752678f8210020/src/controller.tsx#L46-L51

Copy link

vercel bot commented Mar 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
console ✅ Ready (Inspect) Visit Preview Mar 27, 2024 7:07pm

Copy link
Contributor

@charliepark charliepark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

@david-crespo david-crespo merged commit e2a7bcd into main Mar 27, 2024
@david-crespo david-crespo deleted the use-controller branch March 27, 2024 20:07
david-crespo added a commit that referenced this pull request Mar 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants