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

197
Visualizações
What is ?. in JSX?

I see sometimes in JSX this being using ?.

For example

const featuredImageInfo = {
  url,
  // eslint-disable-next-line camelcase
  alt: image?.alt_text,
};

I get invalid token unless i remove the ?. What is it for?

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

0

This is called Optional chaining but not specific to JSX.

It is safe way to access the nested object properties even if an intermediate property doesn’t exist.

Optional chaining props?.value means if the property exist then get the value of that else assign undefined.

const z = {
  test: {
    key: "val"
  }

};

console.log(z.test.key);
console.log(z.test2?.key)
console.log(z.test2.key) // error

In the above example you can see while using optional chaining it logs undefined when property does not exist , without it , it throws error

about 4 years ago · Juan Pablo Isaza Relatório

0

it's called Optional Chaining;) https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html

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