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

191
Vistas
Why does JSX parse empty spaces as children

I just realized that I can pass empty strings as children in react.

function App() {
  return (
    <Comp> {} {} </Comp>
  );
}

Here is the result directly copy pasted from React Developer Tools.

{
  "children": [
    " ",
    " ",
    " "
  ]
}

I found a Github issue describing this. The issue is closed because that is an expected behavior.

My question is, what is the use case for something like that? Why is this an intended behavior?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Whitespace is text. Text is a node. That's really all there is to it.

And the code has three separate whitespace nodes:

<Comp> {} {} </Comp>
      ^--^--^--- here

How much whitespace is there doesn't make a difference, or what other text is there doesn't make a difference. All that matters in this case is that there are three distinct elements of text (separated by curly braces, which are coincidentally empty but still exists and delineate the text for the parser).

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