[Bug]: Cannot assign to read only property '0' of object '[object Array]'
See original GitHub issueVersion 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:
- Created 2 years ago
- Comments:9 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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.
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))).