DEV Community

Discussion on: What in the Heck is JSX ?

Collapse
 
florianrappl profile image
Florian Rappl

JSX is a concise HTML like structure in the same file as we write the JavaScript code. Unlike in the past, we can put HTML into JavaScript.

Sorry that I need to be pedantic here. Its more XML like and we cannot just put HTML into JS.

For instance, the following is totally legit HTML

<ul>
  <li>1
  <li>2
  <li>3
</ul>
Enter fullscreen mode Exit fullscreen mode

however, will result in invalid JSX. There are multiple other examples where both differ significantly.

You can use React without JSX but here is why most don't.

Sure - and you can also use JSX without React. Both are totally independent. JSX can be useful for many many things - going actually beyond VDOM. Many tree structures can be very nicely described with diamond brackets.

Otherwise nice article - thanks!

Collapse
 
aaronsm46722627 profile image
Aaron Smith • Edited

Hi Florian,

Thank you for taking the time to be detail orientated with my article. These articles I'm writing are to document my learning and focus my understanding of the library and I'm glad when people like you help fill in any gaps I've missed. The beauty is that, these articles can be updated, what you're saying about it being more XML like make sense to me and will edit this in response.

It's interesting you say about JSX being useful for tree structures. You're absolutely right about this and something when I was writing this article up was thinking about the consequences of this. Have you seen any other use cases for this ?

Kind regards
Aaron