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

157
Visualizações
Uncaught Typeerror: cant read properties of (undefined) reading 'message'

I'm making a simple library which turns JS objects into JS class componeents to register and use in HTML. I'm testing it with a simple object:

const myEle = {
state: {
message: `Hello World`
},
template: `<p> ${this.state.message} </p>`,
style: {
color: "red"
},
hooks: {
onClick: () => alert("Hi!")
},
attrs: {},
element: toComp(this.template, this.style, this.state, this.hooks, this.attrs)
}

Specifically, the error is with template. which gives me the error mentioned in the title, despite this.state.messagemaking snese ti ne. Why is that happening?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You can't access the object during its initialization with object literal syntax.

This is invalid javascript:

const obj = {
  property1: 'hello',
  property2: property1
};

You can access it after its initialization:

const obj = {
  property1: 'hello',
};
obj.property2: property1;

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