Controller behaving differently for nested input, react-select #12977
Unanswered
kunal215-sortly
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Here is CSB: https://codesandbox.io/p/sandbox/react-hook-form-v7-ts-setvalue-forked-h759g3.
In my project's codebase, I want to set value of a controlled input from outside using setValue. I got to know from a discussion thread: #7758 that Controller internally subscribes to value updates happening to exact field name and hence, setting value without exact fieldName won't work. I found an exception when I included input element inside Controller (I know that input element can be treated as uncontrolled but wanted to give a try) and it is a nested field in form state.
Expectation: on clicking set button, formValues should have been updated and Controller shouldn't have given new value to nested input.
Current: on clicking set button, formValues got updated and Controller gives new value to input.
Expectation is still valid for Select component from React-Select which is also present as a nested field. Can anyone please help me with reasoning behind this strange behavior ?
Also, @bluebill1049 @Moshyfawn and other maintainers, Can you guys please help me in understanding why going ahead with exact field name's value update was decided for useController ?
Beta Was this translation helpful? Give feedback.
All reactions