TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Why Did React Switch to ES6 Classes?

1 pointsby jan-jakubabout 8 years ago
I tried to find a justification for that change in the API, but couldn't find any. Using ES6 Classes in React seems more tedious to me, as I have to bind methods manually, so I see one downside and no upsides. Is it known what was the React guys' reasoning behind that switch?

1 comment

acemarkeabout 8 years ago
The React team has discussed this many times.<p>`React.createClass` was created at a time when there were no classes as part of the JS language itself, and every library was busy inventing its own class-like inheritance implementation. Now that that classes are an actual part of the language, they&#x27;re a common standard of syntax and behavior that tools can understand, so there&#x27;s no reason to keep using a homegrown implementation. In addition, in React 16 the React team will remove `createClass` from the main React package and move it into a separate package, thus shrinking package size.<p>There&#x27;s a variety of approaches to manage method binding. See the &quot;Using React with ES6&quot; section of my links list for discussion and information: <a href="https:&#x2F;&#x2F;github.com&#x2F;markerikson&#x2F;react-redux-links&#x2F;blob&#x2F;master&#x2F;using-react-with-es6.md" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;markerikson&#x2F;react-redux-links&#x2F;blob&#x2F;master...</a><p>(I&#x27;d normally go dig up some links to comments from the React team, but I&#x27;ll leave that as an exercise for the asker this time - trust me, you shouldn&#x27;t have to look too hard.)