Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

287
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda