Do I really need Babel or other transpilers to use ES6 in React?
I was looking at the chart https://kangax.github.io/compat-table/es6/
Seems like my current browser Chrome (latest stable version) supports almost all the ES6 features...
If I can use ES6 without Babel, how I should do it?
If you work on a React project, chances are you have to deal with Babel. It is needed for 2 main tasks: To compile JSX into React.
Using modern language features and browser APIs makes writing code easier, faster, and more fun. It also makes your code more maintainable. If you're happy writing ES5 and using XMLHttpRequest() , you definitely don't need Babel, but you might need some kind of therapy.
Whenever we write React Code, we always build/transpile it to JavaScript that browsers can understand. This is generally done with tools like Babel or TypeScript. If you use tools and libraries like Create React App, they will do the transpilation for you behind the scenes.
js and it supports ES6 features, you don't need to transpile your code. Your code only works in the same place, if it is hosted in one place. Transpiler is used, when your code is written in newer versions, there may be users which use browsers with old versions of Javascript.
If you want to:
modules
(with require()
or import ...
)JSX
You must use Babel to be sure that everyone will be able to run your code, else you can develop without it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With