Relative Content

Tag Archive for reactjsreact-hook-form

Read defaultValue programmatically in React Hook Form

I have two Select boxes that represent a key value pair. The selected Key value filters the Values options when onChange is called. This works fine for new items, but when I load in an object, the Values Select box doesn’t load any options because it is empty until a Key has been selected and defaultValue doesn’t trigger onChange. Is there a way to read the defaultValue, perhaps in a useEffect block to mimic the onChange event and populate the Values options?