Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How could I know I am using ES6 in React?

I am trying to use react.js. I found a question while I am reading the "get started with react". (link : https://facebook.github.io/react/docs/getting-started.html)

Middle of the page, there is a statement,

Note: If you are using ES2015, you will want to also use the babel-preset-es2015 package.

However, I do not know how to find which one I am using. How could I find which one I am using?

SUM >> How could I know ES version?

like image 398
Juneyoung Oh Avatar asked Oct 30 '22 14:10

Juneyoung Oh


2 Answers

However, I do not know how to find which one I am using. How could I find which one I am using?

You can check in the package.json of your project. Normally, you will find under the devDependencies property something that looks this way: "babel-preset-es2015": "x.y.z" (x.y.z being the version you use)

It refers to this npm package

Hope this helps.

EDIT: the answer to your question:

SUM >> How could I know ES version?

is pretty straightforward. Check ES2015 specific syntatic features in your codebase.

like image 153
Mayas Avatar answered Nov 08 '22 05:11

Mayas


If you are using import xy from './xy' to request your modules, you are using ES6. If you are using var xy = require('./xy') to request your modules, you are not. ES6 offers a lot more than that though, but there are hundreds of articles about that already. For example classes are new in ES6. Btw, ES6 = ECMAScript 2015: https://en.wikipedia.org/wiki/ECMAScript

Also, if you are using Babel in your project, you are using ES6. For older Browsers, you need to "transpile" the code to work.

Btw, every developer should have heard of ES6 by now, and i highly recommend using it already.

like image 30
andyrandy Avatar answered Nov 08 '22 05:11

andyrandy