Hacker News new | ask | show | jobs
by danmaz74 4002 days ago
We're considering trying react for a new project, and just read about the adoption of Babel [1] instead of the internal transpiler previously used for JSX. One question: does this mean that JSX will be able to use ES6 syntax supported by Babel out of the box? If so, will this be the default for this new version of React?

I ask the questions also because we would really like to be able to use React with CoffeeScript, but, even if there are many solutions to do so, no one is supported by Facebook and we're worried about future compatibility. Is adopting Babel going to influence the ability to use React with CS?

[1] https://facebook.github.io/react/blog/2015/06/12/deprecating...

4 comments

You don't need to use Babel, though we do recommend it. We're just no longer going to maintain our own JSX transformer since there's no point. (If you want just Babel's JSX transformation without any other features, that's possible too.)

There's a CoffeeScript JSX transformer here if you're interested:

https://github.com/jsdf/coffee-react

and we'll continue to support using React without JSX, and though we use Babel now internally, we compile React itself to ES5 before putting it on npm so you don't need to use Babel if you don't want to.

Thanks for the answer. It would be great to have an officially sanctioned toolchain for using coffee and react from Rails, but I think that asking too much :)
I've been using babel instead of the internal transpiler and yes you can use all the ES6 syntax out of the box.

I think the JSX transpiler was deprecated some time ago and pretty much all the react starter templates and examples have been using Babel.

I don't think adopting babel is going to compromise your use of coffeescript, in then babel is just transpiling down to old style javascript.

So you were using babel with a JSX module? Did they just make the JSX module the default? Sorry but I know babel only by name yet!
React's deprecation of JSTransform means that you will (whenever they completely remove it) need to actually use Babel to build your React JavaScript.
From personal experience I'll just use ES6.

It's not about the HTML-like JSX part using ES6 or using native classes to extend React.component(with limitations), but simpler object literals, fat arrows and { foo: foo } becoming { foo } make React code look much better. I can endure the ending semicolons, parens and brackets.

Now you don't really gain too much by opting for CS over ES6 for React. And with React's adoption of Babel I think ES6 is going to become the primary way of writing React apps.

I still like CS better than ES6, but I agree the latter is the most likely winner combination with React. Maybe I just need to find an editor that masks the unnecessary parens and semicolons :)