How to re-render using setValue() in FormContext

Viewed 25

I am struggling to re-render when I am using setValue to dynamically set the value of a registered field.

I have created the below sandbox to showcase the issue: https://codesandbox.io/s/react-hook-form-v7-form-context-forked-ojp8ee?file=/src/Test.js

In Test.js, I have a radio group which has a handleChange to switch type and value attributes. I can see the updated value in the input box but for the p it never updates the values.

I am confused what I am missing. I did add shouldDirty: true as well as mentioned here: https://react-hook-form.com/api/useform/setvalue

Any help appreciated!

Thanks

0 Answers
Related