Replies: 1 comment 1 reply
-
You can do this
Or look for custom equality comparator in MUI Select component. I don't remember any, but here is the closed issue mui/material-ui#24201 |
Beta Was this translation helpful? Give feedback.
1 reply
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.
-
Version Number
7.52.0
Codesandbox/Expo snack
https://codesandbox.io/p/sandbox/react-hook-form-setvalue-with-object-array-lost-reference-vy45yy?file=%2Fpackage.json
Steps to reproduce
Toggle an item in
MUI Select with RHF
. Observer that the item is pushed to field value every time selected.I guess it's because when the internal
setValue
is called with array of object, something additional like cloning happened as well. Thus, the value reference is lost, which makes the MUI Select cannot decide what options are selected.Expected behaviour
Toggle an item in
MUI Select without RHF
. That's the expected behavior.issue.-.setValue.with.object.array.makes.lost.of.reference.mov
What browsers are you seeing the problem on?
Chrome
Relevant log output
No response
Code of Conduct
Beta Was this translation helpful? Give feedback.
All reactions