The React Team over at Facebook has shipped React v0.13, bringing with it a changelog full of breaking changes and new features. The most important new feature comes in the form of support for ES2015-classes, to give developers more flexibility when writing new components.
Ben Alpert from React was optimistic about the team’s eventual goals for ES6 class support:
Our eventual goal is for ES6 classes to replace
React.createClasscompletely, but until we have a replacement for current mixin use cases and support for class property initializers in the language, we don’t plan to deprecate
Some of the breaking changes that come up in v0.13 include the following:
- Deprecated patterns that warned in 0.12 no longer work: most prominently, calling component classes without using JSX or React.createElement and using non-component functions with JSX or createElement
propsafter an element is created is deprecated and will cause warnings in development mode; future versions of React will incorporate performance optimizations assuming that props aren’t mutated
- Static methods (defined in
statics) are no longer autobound to the component class
A bunch of new top-level APIs have also been revealed, such as React.findDOMNode () and React.cloneElement (), as well as a new
ref style, allowing a callback to be used in place of a name.
SEE ALSO: Facebook announces React Native
Alpert was on hand to interact with users after the news broke, who comments regularly on Hacker News as user spicyj. He had this to say in reply to a user’s curiosity about how mixins will work out in ES6:
Most cases of mixins (especially ones that involve state, as you allude to) can be implemented via composition by creating wrapper components instead. This is how Relay works and makes different components more contained and easier to reason about.
The full release announcement concerning React v0.13 is available here.