-
I meet Firstly, I haven't been able to directly provide the result of const foobar = useSelector((state) => state.foobar);
const { reset } = useForm({
defaultValues: cloneDeep(foobar)
}); After that, I've still been meeting that issue after form submitting. I've been able to reproduce it in a basic example: https://codesandbox.io/s/react-hook-form-cannot-assign-to-read-only-property-ip14f (Just add a media by clicking on Any idea? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
The root cause is from line 72 where form data is persisted in Redux store, it will transform the object to immutable object but this object is used by react-hook-form to get and set value on ref. Cloning form data before persisting it to Redux store will fix the issue. Working sample: https://codesandbox.io/s/react-hook-form-cannot-assign-to-read-only-property-forked-nqkk7 |
Beta Was this translation helpful? Give feedback.
@oltodo
The root cause is from line 72 where form data is persisted in Redux store, it will transform the object to immutable object but this object is used by react-hook-form to get and set value on ref.
Cloning form data before persisting it to Redux store will fix the issue.
Working sample: https://codesandbox.io/s/react-hook-form-cannot-assign-to-read-only-property-forked-nqkk7