How to add a react-select dropdown with react-hook-form in React

In this article, we will show you how to add a react-select dropdown with react-hook-form in React. Similarly, you can implement other packages with a React Hook Form.

Here, we will continue the previous article so advise you to go through that article.

Validate a form in React using react-hook-form

Demo Application

Output - How to add a react-select dropdown with react-hook-form in React - Clue Mediator
Output – How to add a react-select dropdown with react-hook-form in React – Clue Mediator

Add a react-select dropdown with react-hook-form in React

  1. Create a simple form
  2. Add a react-select dropdown in form
  3. Output

1. Create a simple form

Refer to the following articles, If you don’t know how to create a form using react-hook-form.

2. Add a react-select dropdown in form

Here, we’ll use the react-select npm package to add the dropdown in the form.

To add the third party package, we have to use the useController from the react-hook-form.

As you can see in the above code, we have used the control in the useController. So don’t forget to export control from the useForm().

Now, let’s use the above exported method in the react-select.

3. Output

Let’s put all the code together and see how it looks.

App.js

Run the application and check the output in the browser.

I hope you find this article helpful.
Thank you for reading. Happy Coding..!! 🙂

Demo & Source Code

GitHub Repository StackBlitz Project
If you found value in this article,
you can support us by buying me a coffee! ☕

You may also like...

2 Responses

  1. Tibério Brasil says:

    Thank you so much, it helped a lot. Keep doing the nice work.

Leave a Reply

Your email address will not be published. Required fields are marked *