Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSX vs ES6/ES2015

In my project I'm using React and Babel so I use some ES6 features but mainly those used by React. Webstorm gives me the option to mark my syntax either as ES6 or JSX Harmony and I got confused.

I think I know what ES6/ES2015 is and how to use it with a compiler, eg. Babel.

The hard part id JSX/JSX Harmony. I know that React uses "JSX" but:

  1. Is this the same JSX as here? If not, which JSX is meant by JSX Harmony option in Webstorm?

  2. I've seen the compatibility page mentioned here and know that JSX Transformer supports only small part of ES6 but also that apparently Babel supports JSX as an addition to ES6 support so JSX seems to be more than ES6 subset... If so, what features of JSX React or JSX Harmony are not part of ES6 specs?

EDIT:

As for question 1 I'm getting sure, these are two completely different things. But what is JSX Harmony then?

EDIT 2:

To answer my own question, Webstorm JSX Harmony refers most probably to the syntax supported by React JSX Compiler with --harmony flag on - adding a bit of ES6 support.

like image 698
konrad Avatar asked Sep 22 '15 03:09

konrad


People also ask

Is JSX and ES6 same?

In Conclusion.. JSX stands for “JavaScript XML,” and it is a syntax extension to JavaScript based in ES6, the newest “version” of JavaScript. JSX allows you to write HTML in React by converting HTML into React components, helping you to more easily create user interfaces for your web applications.

Is ES6 the same as ES2015?

You see, ES6 and ES2015 are the same thing. ES6 was the popularized name prior to release. However, the committee that oversees ECMAScript specifications made the decision to move to annual updates. With this change, the edition was renamed to ES 2015 to reflect the year of release.

Is JSX part of ECMAScript?

This specification does not attempt to comply with any XML or HTML specification. JSX is designed as an ECMAScript feature and the similarity to XML is only for familiarity.

Which is better JSX or JS?

Both JS and JSX are interchangeable but JSX makes the code easier to understand for users. JSX is popularly used in React, as it makes the job of building an application much easier.


1 Answers

No, it's not the same jsx. There are two languages called JSX that I know of:

  1. The templating language for React.js

  2. A statically typed programming language that compiles down to javascript.

The two languages are as different as XML and C++.

The JSX you're looking for is from here: https://github.com/facebook/react and can be installed via npm from here: https://www.npmjs.com/package/react-tools

The JSX programming language will not compile React JSX templates.

like image 116
slebetman Avatar answered Oct 14 '22 21:10

slebetman