React v0.13.1

March 16, 2015 by Paul O’Shannessy


It's been less than a week since we shipped v0.13.0 but it's time to do another quick release. We just released v0.13.1 which contains bugfixes for a number of small issues.

Thanks all of you who have been upgrading your applications and taking the time to report issues. And a huge thank you to those of you who submitted pull requests for the issues you found! 2 of the 6 fixes that went out today came from people who aren't on the core team!

The release is now available for download:

We've also published version 0.13.1 of the react and react-tools packages on npm and the react package on bower.


Changelog #

React Core #

Bug Fixes #

  • Don't throw when rendering empty <select> elements
  • Ensure updating style works when transitioning from null

React with Add-Ons #

Bug Fixes #

  • TestUtils: Don't warn about getDOMNode for ES6 classes
  • TestUtils: Ensure wrapped full page components (<html>, <head>, <body>) are treated as DOM components
  • Perf: Stop double-counting DOM components

React Tools #

Bug Fixes #

  • Fix option parsing for --non-strict-es6module

React v0.13

March 10, 2015 by Ben Alpert


Today, we're happy to release React v0.13!

The most notable new feature is support for ES6 classes, which allows developers to have more flexibility when writing components. Our eventual goal is for ES6 classes to replace React.createClass completely, 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 React.createClass.

At EmberConf and ng-conf last week, we were excited to see that Ember and Angular have been working on speed improvements and now both have performance comparable to React. We've always thought that performance isn't the most important reason to choose React, but we're still planning more optimizations to make React even faster.

Our planned optimizations require that ReactElement objects are immutable, which has always been a best practice when writing idiomatic React code. In this release, we've added runtime warnings that fire when props are changed or added between the time an element is created and when it's rendered. When migrating your code, you may want to use new React.cloneElement API (which is similar to React.addons.cloneWithProps but preserves key and ref and does not merge style or className automatically). For more information about our planned optimizations, see GitHub issues #3226, #3227, #3228.

The release is now available for download:

We've also published version 0.13.0 of the react and react-tools packages on npm and the react package on bower.


Changelog #

React Core #

Breaking Changes #

  • 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
  • Mutating props after 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
  • ref resolution order has changed slightly such that a ref to a component is available immediately after its componentDidMount method is called; this change should be observable only if your component calls a parent component's callback within your componentDidMount, which is an anti-pattern and should be avoided regardless
  • Calls to setState in life-cycle methods are now always batched and therefore asynchronous. Previously the first call on the first mount was synchronous.
  • setState and forceUpdate on an unmounted component now warns instead of throwing. That avoids a possible race condition with Promises.
  • Access to most internal properties has been completely removed, including this._pendingState and this._rootNodeID.

New Features #

  • Support for using ES6 classes to build React components; see the v0.13.0 beta 1 notes for details.
  • Added new top-level API React.findDOMNode(component), which should be used in place of component.getDOMNode(). The base class for ES6-based components will not have getDOMNode. This change will enable some more patterns moving forward.
  • Added a new top-level API React.cloneElement(el, props) for making copies of React elements – see the v0.13 RC2 notes for more details.
  • New ref style, allowing a callback to be used in place of a name: <Photo ref={(c) => this._photo = c} /> allows you to reference the component with this._photo (as opposed to ref="photo" which gives this.refs.photo).
  • this.setState() can now take a function as the first argument for transactional state updates, such as this.setState((state, props) => ({count: state.count + 1})); – this means that you no longer need to use this._pendingState, which is now gone.
  • Support for iterators and immutable-js sequences as children.

Deprecations #

  • ComponentClass.type is deprecated. Just use ComponentClass (usually as element.type === ComponentClass).
  • Some methods that are available on createClass-based components are removed or deprecated from ES6 classes (getDOMNode, replaceState, isMounted, setProps, replaceProps).

React with Add-Ons #

New Features #

Deprecations #

  • React.addons.classSet is now deprecated. This functionality can be replaced with several freely available modules. classnames is one such module.
  • Calls to React.addons.cloneWithProps can be migrated to use React.cloneElement instead – make sure to merge style and className manually if desired.

React Tools #

Breaking Changes #

  • When transforming ES6 syntax, class methods are no longer enumerable by default, which requires Object.defineProperty; if you support browsers such as IE8, you can pass --target es3 to mirror the old behavior

New Features #

  • --target option is available on the jsx command, allowing users to specify and ECMAScript version to target.
    • es5 is the default.
    • es3 restores the previous default behavior. An additional transform is added here to ensure the use of reserved words as properties is safe (eg this.static will become this['static'] for IE8 compatibility).
  • The transform for the call spread operator has also been enabled.

JSX #

Breaking Changes #

  • A change was made to how some JSX was parsed, specifically around the use of > or } when inside an element. Previously it would be treated as a string but now it will be treated as a parse error. The jsx_orphaned_brackets_transformer package on npm can be used to find and fix potential issues in your JSX code.

Community Round-up #25

March 4, 2015 by Matthew Johnston


React 101 #

Interest in React has been exploding recently, so it's a good time to explore some great recent tutorials and videos that cover getting started.

Ryan Clark provides a great overview of the basics of React with the goal of building a really simple dropdown nav.

Formidable Labs and Seattle JS recently hosted a series of React, Flux, and Flow workshops, and the first part is available to watch online:

AEFlash writes up some best practices and tips to help you avoid potential pitfalls when developing with React.

Black Mutt Media takes us through their usage of React and Ruby to build an autocomplete field, and some of the pitfalls they encountered along the way.

Our own Sebastian Markbåge was on the Web Platform Podcast to have a chat about all aspects of React.

Community Additions #

Formidable Labs have been busy, as they've also just launched Radium, a React component that provides you with the ability to use inline styles instead of CSS. They're also looking for some help contributing to a Radium Bootstrap implementation.

Reactiflux.com is a new Slack community based around (you guessed it!) React, and Flux.

React Week is a week-long learning workshop, happening next week, for React, Flux, and other related technologies, run by Ryan Florence.

Babel-sublime is a new package which provides Sublime with language definitions for ES6 JavaScript with React JSX syntax extensions.

react-meteor, a package that replaces the default templating system of the Meteor platform with React, recently received a big update.

Rebuilding with React #

Rich Manalang from Atlassian explains why they rebuilt their HipChat web client from scratch using React, and how they're already using it to rebuild their native desktop clients.

Andrew Hillel of the BBC gives an excellent and thorough breakdown of the stack they used to rebuild their homepage, with React as an integral part of the front-end.

A team from New Zealand called Atomic is building web and mobile prototyping and design tools entirely in-browser, and as co-founder Darryl Gray says, “React.js “totally changed” the fact that browser performance often wasn’t good enough for complex tools like this.”.

Polarr have rebuilt their browser-based photo editor with React.

It's F8! #

F8 2015 is just around the corner, and you can sign up for the video streams in advance because we're sure to be covering all things React.

Meetups #

React v0.13 RC2

March 3, 2015 by Sebastian Markbåge


Thanks to everybody who has already been testing the release candidate. We've received some good feedback and as a result we're going to do a second release candidate. The changes are minimal. We haven't changed the behavior of any APIs we exposed in the previous release candidate. Here's a summary of the changes:

  • Introduced a new API (React.cloneElement, see below for details).
  • Fixed a bug related to validating propTypes when using the new React.addons.createFragment API.
  • Improved a couple warning messages.
  • Upgraded jstransform and esprima.

The release candidate is available for download:

We've also published version 0.13.0-rc2 of the react and react-tools packages on npm and the react package on bower.


React.cloneElement #

In React v0.13 RC2 we will introduce a new API, similar to React.addons.cloneWithProps, with this signature:

React.cloneElement(element, props, ...children);

Unlike cloneWithProps, this new function does not have any magic built-in behavior for merging style and className for the same reason we don't have that feature from transferPropsTo. Nobody is sure what exactly the complete list of magic things are, which makes it difficult to reason about the code and difficult to reuse when style has a different signature (e.g. in the upcoming React Native).

React.cloneElement is almost equivalent to:

<element.type {...element.props} {...props}>{children}</element.type>

However, unlike JSX and cloneWithProps, it also preserves refs. This means that if you get a child with a ref on it, you won't accidentally steal it from your ancestor. You will get the same ref attached to your new element.

One common pattern is to map over your children and add a new prop. There were many issues reported about cloneWithProps losing the ref, making it harder to reason about your code. Now following the same pattern with cloneElement will work as expected. For example:

var newChildren = React.Children.map(this.props.children, function(child) {
  return React.cloneElement(child, { foo: true })
});

Note: React.cloneElement(child, { ref: 'newRef' }) DOES override the ref so it is still not possible for two parents to have a ref to the same child, unless you use callback-refs.

This was a critical feature to get into React 0.13 since props are now immutable. The upgrade path is often to clone the element, but by doing so you might lose the ref. Therefore, we needed a nicer upgrade path here. As we were upgrading callsites at Facebook we realized that we needed this method. We got the same feedback from the community. Therefore we decided to make another RC before the final release to make sure we get this in.

We plan to eventually deprecate React.addons.cloneWithProps. We're not doing it yet, but this is a good opportunity to start thinking about your own uses and consider using React.cloneElement instead. We'll be sure to ship a release with deprecation notices before we actually remove it so no immediate action is necessary.

React v0.13 RC

February 24, 2015 by Paul O’Shannessy


Over the weekend we pushed out our first (and hopefully only) release candidate for React v0.13!

We've talked a little bit about the changes that are coming. The splashiest of these changes is support for ES6 Classes. You can read more about this in our beta announcement. We're really excited about this! Sebastian also posted earlier this morning about some of the other changes coming focused around ReactElement. The changes we've been working on there will hopefully enable lots of improvements to performance and developer experience.

The release candidate is available for download:

We've also published version 0.13.0-rc1 of the react and react-tools packages on npm and the react package on bower.


Changelog #

React Core #

Breaking Changes #

  • Mutating props after 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
  • ref resolution order has changed slightly such that a ref to a component is available immediately after its componentDidMount method is called; this change should be observable only if your component calls a parent component's callback within your componentDidMount, which is an anti-pattern and should be avoided regardless
  • Calls to setState in life-cycle methods are now always batched and therefore asynchronous. Previously the first call on the first mount was synchronous.
  • setState and forceUpdate on an unmounted component now warns instead of throwing. That avoids a possible race condition with Promises.
  • Access to most internal properties has been completely removed, including this._pendingState and this._rootNodeID.

New Features #

  • Support for using ES6 classes to build React components; see the v0.13.0 beta 1 notes for details
  • Added new top-level API React.findDOMNode(component), which should be used in place of component.getDOMNode(). The base class for ES6-based components will not have getDOMNode. This change will enable some more patterns moving forward.
  • New ref style, allowing a callback to be used in place of a name: <Photo ref={(c) => this._photo = c} /> allows you to reference the component with this._photo (as opposed to ref="photo" which gives this.refs.photo)
  • this.setState() can now take a function as the first argument for transactional state updates, such as this.setState((state, props) => ({count: state.count + 1})); -- this means that you no longer need to use this._pendingState, which is now gone.
  • Support for iterators and immutable-js sequences as children

Deprecations #

  • ComponentClass.type is deprecated. Just use ComponentClass (usually as element.type === ComponentClass)
  • Some methods that are available on createClass-based components are removed or deprecated from ES6 classes (for example, getDOMNode, setProps, replaceState).

React with Add-Ons #

Deprecations #

  • React.addons.classSet is now deprecated. This functionality can be replaced with several freely available modules. classnames is one such module.

React Tools #

Breaking Changes #

  • When transforming ES6 syntax, class methods are no longer enumerable by default, which requires Object.defineProperty; if you support browsers such as IE8, you can pass --target es3 to mirror the old behavior

New Features #

  • --target option is available on the jsx command, allowing users to specify and ECMAScript version to target.
    • es5 is the default.
    • es3 restored the previous default behavior. An additional transform is added here to ensure the use of reserved words as properties is safe (eg this.static will become this['static'] for IE8 compatibility).
  • The transform for the call spread operator has also been enabled.

JSX #

Breaking Changes #

  • A change was made to how some JSX was parsed, specifically around the use of > or } when inside an element. Previously it would be treated as a string but now it will be treated as a parse error. We will be releasing a standalone executable to find and fix potential issues in your JSX code.