Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

199
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda