JavaScript React Basics (retired) First Steps in React JSX Review

Ana María Benites Rodríguez
Ana María Benites Rodríguez
966 Points

JSX syntax is the same as HTML in JavaScript files.

why is this statement false? thanks!

2 Answers

It’s an HTML-like syntax for writing JavaScript, but its still javascript

Robert Schaap
Robert Schaap
19,836 Points

It looks like HTML which is useful during development, but it actually just compiles down to JavaScript. Think of it like this, when you're typing <div>Ana</div>, what you're actually typing under the hood is React.createElement("div", null, "Ana"); The nice JSX syntax is syntactic sugar as it's called.

edit- if you want to get an idea, head over to www.babeljs.io, there you can type some JSX or plain JS and see what it compiles to.