Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

293
Views
Cannot assign to read only property (value) of object '#<Object>'

I have a function which retrieves an object.

  const removeLogo = (values: any) => {
   values.settings.logoUrl = undefined;
  setMaster({ ...values });
  };

my object is the following :

 values = {
  name: "test",
  reference: "ref"
  settings: {
  logoUrl : 'url'
 }
}

in this object I simply want to change a value :

values.settings.logoUrl = undefined;

but I end up with a following error message :

 form-mail-reminders.tsx:83 Uncaught TypeError: Cannot assign to read only property 
 'logoUrl' of object '#<Object>'

Is there a solution to modify the value of the object without having this error message ?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You need to set the property of the objects to writeable as they are set to non writeable.

writable

true if and only if the value associated with the property may be changed with an assignment operator. Defaults to false.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperties

And for you:

Object.defineProperty(values, 'logoUrl', {
   writable:true
});
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!