Skip to content

Upgrading react 0.12 to 0.13

Breaking0.12.2 → 0.13.3Breaking8Deprecated5New14Changed5Fixed13Other1

BreakingUpgrade verdict

8 breaking changes.

  • Code that React 0.12 only warned about now fails: you must create components with JSX or React.createElement, and only real components can be used that way.
  • Methods you declare in statics no longer automatically have this bound to the component class.
  • Compiled ES6 class methods are no longer enumerable, which needs Object.defineProperty. For IE8, use --target es3 to keep the old behavior.
  • Refs to a child component are now set right after that child's componentDidMount runs, which only matters if you call a parent callback from componentDidMount.
Top 5 of 13 that need code or config changes
Breaking8
Deprecated patterns that warned in 0.12 no longer work, including calling component classes without JSX or React.createElement and using non-component functions with JSX or createElement.
React.createElement
Static methods defined in statics are no longer autobound to the component class.
statics
When transforming ES6 syntax, class methods are no longer enumerable by default, requiring Object.defineProperty; pass --target es3 for IE8.
Object.defineProperty--target es3
Ref resolution order changed so a ref to a component is available immediately after its componentDidMount is called.
componentDidMountref
setState calls in life-cycle methods are now always batched and asynchronous; previously the first call on first mount was synchronous.
setState
setState and forceUpdate on an unmounted component now warn instead of throwing, avoiding a possible race condition with Promises.
setStateforceUpdate
Access to most internal properties is completely removed, including this._pendingState and this._rootNodeID.
this._pendingStatethis._rootNodeID
Changes JSX parsing so > or } inside an element is now a parse error instead of a string.
jsx_orphaned_brackets_transformer
Deprecated5
Mutating props after an element is created is deprecated and warns in development mode; future versions assume props are not mutated.
props
ComponentClass.type is deprecated; use ComponentClass directly, usually as element.type === ComponentClass.
ComponentClass.typeComponentClasselement.type
Some createClass-based component methods are removed or deprecated from ES6 classes: getDOMNode, replaceState, isMounted, setProps, replaceProps.
getDOMNodereplaceStateisMountedsetPropsreplaceProps
React.addons.classSet is deprecated; use a module such as classnames instead.
React.addons.classSet
React.addons.cloneWithProps calls can be migrated to React.cloneElement, merging style and className manually if desired.
React.addons.cloneWithPropsReact.cloneElement