News for hackers. Stuff that matters.
Re:React v0.12 by jaredgrippe on Tuesday October 28, 2014 @07:51PM (#8524529)
The object literal syntax also sucks :(

https://gist.github.com/deadlyicon/79c09610cac5a67f4a5d

Re:React v0.12 by spion on Tuesday October 28, 2014 @08:17PM (#8524654)
Agreed.

* JSX more tightly coupled,

* less straightforward JSX->JS mapping - I used to be so excited to tell people how JSX simply maps to function calls in JS... well, now it generates boilerplate instead.

* worse non-JSX syntax

I don't buy the ES6/CS/TS argument - wrapping classes with createFactory before exporting seems fine to me, and I use typescript. Also, from what I can see the object literal syntax is always worse.

So its basically all about Jest. The only reason I see is that a mocking tool can't handle factories. Makes me a bit sad. Seems like a good example of "test induced design damage" to me. How about adding plugins to that mocking tool instead?

Re:React v0.12 by peterhunt on Tuesday October 28, 2014 @08:29PM (#8524703)
If you wrap the class in createFactory() then you break instanceof; how is this fine?
Re:React v0.12 by spion on Tuesday October 28, 2014 @08:36PM (#8524740)
True. But I can't come up with an example where I'd use instanceof on react components, can you give me one?
Re:React v0.12 by mateuszf on Wednesday October 29, 2014 @03:27AM (#8525965)
Just wondering .. maybe it's used internally by the library?
Re:React v0.12 by chenglou on Tuesday October 28, 2014 @08:29PM (#8524704)
See my link on sebmarkbage's reply. It's not just for Jest.
Re:React v0.12 by spion on Tuesday October 28, 2014 @08:41PM (#8524767)
Okay, except for JSX I agree that the change towards native classes is for the better.

But the change in JSX seems to be just for Jest. JSX could still compile to function calls and stay completely decoupled from React. A new function `createFactory` would be introduced that takes a class argument and produces a factory, making ES6, CS and TS users pleased. No backward-compatibility breakage would be introduced.

edit: removed a non-constructive paragraph. Will play around with the new version more before commenting further. Hopefully I'll understand why JSX is a lot more complicated than it used to be :/