Skip to content

Support for react hook form #105

Answered by csandman
zac-ng asked this question in Q&A
Discussion options

You must be logged in to vote

If you look at the docs for the Controller component, this is what it says

React Hook Form embraces uncontrolled components and native inputs, however it's hard to avoid working with external controlled component such as React-Select, AntD and Material-UI. This wrapper component will make it easier for you to work with them.

You were never able to natively use react-select with react-hook-form and seeing as this is just a wrapper for it, it will be no different. However, its very simple to implement with a custom controller! Here's an example:

<Controller
  control={control}
  name="food"
  rules={{ required: "Please enter at least one food group." }}
  render={({
    field: { onChange,

Replies: 6 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by csandman
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #7 on May 05, 2022 19:29.