react-hook-form watch for text of select not the value

Viewed 272
const { myDropDown} = watch();

returns the value of that, but is there a way with watch() to get the actual text of the select?

As an example my select might be

<select name="myDropDown">
    <option value="1">Cheese</option>
    <option value="2">Ham</option>
</select>

watch() as used above will return me 1 or 2 but I want it to return me Cheese or Ham.

Docs: https://react-hook-form.com/api/useform/watch - didn't seem to help

1 Answers

Had a quick look at the docs, seems like you can to pass watch a parameter.

Like so:

  const watchFields = watch(["showAge", "number"]); // you can also target specific fields by their names

Did you try that?

Found a sandbox example here They wrap a Controller around it and use a DropdownListComponent.

Hope it helps.

Related