TypeError: Cannot assign to read only property 'x' of object
Code tried to modify a frozen object, a getter-only property, or immutable state.
Seen on:
JavaScript
Meaning
Object.freeze, Redux Toolkit/Immer frozen state, and module namespace objects are read-only in strict mode.
Common causes
- Mutating frozen state (Redux/Immer)
- Assigning to a getter-only property
- Modifying an ES module export
⚡ Quick fix
- Create a copy instead of mutating
- Use the setter/action provided
- Update state immutably
Detailed fix by platform
JavaScript
const next = { ...state, count: state.count + 1 };
How to diagnose
- Object — Frozen or getter-only?
- Owner — Which library froze it?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026