Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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

Ana María Benites Rodríguez
Ana María Benites Rodríguez
1,011 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.