[Bug]: Cannot assign to read only property '0' of object '[object Array]'

See original GitHub issue

Version Number

v7

Codesandbox

https://codesandbox.io/s/react-hook-form-get-started-forked-w7zev?file=/src/index.js

Steps to reproduce

Submit form and check console logs

Expected behaviour

I would expect to run this on my system as in codesandbox.

What browsers are you seeing the problem on?

Chrome

Relevant log output

Unlike in Codesandbox I am unable to change checkbox fields getting:  "Cannot assign to read only property '0' of object '[object Array]'".

Code of Conduct

  • I agree to follow this project’s Code of Conduct

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Andreychikov-Vasiliycommented, Sep 9, 2021

@ZipBrandon , for me - on the other hand, I had opposite situation - I got a whole form state from whatch subscription and stored it in redux toolkit store, which under the hood looks like “proxified” this object using immer perhaps. And still as for you I’ve resolved it by doing deepClone before use form state elsewhere.

1reaction
FunctorDevcommented, Dec 10, 2021

I also ran into this problem when setting form value from redux-toolkit selector, I fixed it by using deep clone setValue('arrayField', JSON.parse(JSON.stringify(formValue))).

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot assign to read only property '0' of object ...
I have a page that displays a table. The table displays data from an object array taskList which the component gets as an...
Read more >
Sorting a read-only array is OK if it has only 1 or 0 items
But if the array has 2+ items, attempting to sort it will cause a TypeError. ... Cannot assign to read only property '0'...
Read more >
TypeError: "x" is read-only - JavaScript - MDN Web Docs
The JavaScript strict mode-only exception "is read-only" occurs when a global variable or object property that was assigned to is a read-only property....
Read more >
Cannot assign to read only property '0' of object '[object Array]'
Same here. Seems to be due to color_thresholds, and having multiple items in the list. With a single item, the error goes away,...
Read more >
Cannot assign to read only property '0' of object '[object Array]'
Hi guys, Having this really strange error in several of my cards after updating to latest release ! Thing is, right after I...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found