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

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

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 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