Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

190
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!