Skip to content
Advertisement

React hook form method – setValue – doesn’t work

I have some clearable select, and I want to reset the applets field in state to an empty array.

JavaScript

the problem is that clearing the selection on UI with setValue("applets", []); not working for some reason, and I don’t understand why, and how to do it without reset method, which resets the whole state, not just single property as I understand

Advertisement

Answer

You should always register fields if you want to use them as RHF’s form state.

JavaScript

This fixes an issue.

Update: Also a new method resetField is available

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement