issue: Input field value is not re-rendered in controlled nested array when another array element is selected #11500
Replies: 7 comments 1 reply
-
could you update your CSB? it's missing. |
Beta Was this translation helpful? Give feedback.
-
sorry it was still in drafts, now it should be accessible |
Beta Was this translation helpful? Give feedback.
-
the update would need to be a valid path for that registered controller input. |
Beta Was this translation helpful? Give feedback.
-
sorry I don't understand that. how would a valid path look like if mine is invalid? |
Beta Was this translation helpful? Give feedback.
-
This is the input name which you have registered and this is your setValue |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
yes, but it doesn't work like that. controller is not a state management input (for that entire object), it's just a input which store value for that particular path which you have giving by name/path. you can't do this basically name="test.test.test.test.test.test"
- setValue('test', { test: {test: {test: ''}}})
+ setValue('test.test.test.test.test.test', 'data') |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Version Number
7.50.1
Codesandbox/Expo snack
https://codesandbox.io/p/sandbox/react-hook-form-conditional-forked-j3m6n9?file=%2Fsrc%2Findex.js
Steps to reproduce
see screen recording
bug.mp4
Expected behaviour
When the
selectedIndex
is changed from0
to1
,name
changes fromtest.0.values.${valueIndex}
totest.1.values.${valueIndex}
. I would thus expect that the rendered input values change from["aaa", "bbb", "ccc"]
to["xxx", "yyy", "zzz"]
.A workaround is to use the
name
askey
, then the correct values are rendered:workaround.mp4
What browsers are you seeing the problem on?
Firefox, Chrome
Relevant log output
No response
Code of Conduct
Beta Was this translation helpful? Give feedback.
All reactions