Upgrading react 0.12 to 0.13
Breaking0.12.2 → 0.13.3Breaking8Deprecated5New14Changed5Fixed13Other1
BreakingUpgrade verdict
8 breaking changes.
In plain terms
- 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.
Must act Top 5 of 13 that need code or config changes
What you must change
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.createElementStatic methods defined in statics are no longer autobound to the component class.
staticsWhen transforming ES6 syntax, class methods are no longer enumerable by default, requiring Object.defineProperty; pass --target es3 for IE8.
Object.defineProperty--target es3Ref resolution order changed so a ref to a component is available immediately after its componentDidMount is called.
componentDidMountrefsetState calls in life-cycle methods are now always batched and asynchronous; previously the first call on first mount was synchronous.
setStatesetState and forceUpdate on an unmounted component now warn instead of throwing, avoiding a possible race condition with Promises.
setStateforceUpdateAccess to most internal properties is completely removed, including this._pendingState and this._rootNodeID.
this._pendingStatethis._rootNodeIDChanges JSX parsing so
> or } inside an element is now a parse error instead of a string.jsx_orphaned_brackets_transformerDeprecations to plan for
Deprecated5
Mutating props after an element is created is deprecated and warns in development mode; future versions assume props are not mutated.
propsComponentClass.type is deprecated; use ComponentClass directly, usually as element.type === ComponentClass.
ComponentClass.typeComponentClasselement.typeSome createClass-based component methods are removed or deprecated from ES6 classes: getDOMNode, replaceState, isMounted, setProps, replaceProps.
getDOMNodereplaceStateisMountedsetPropsreplacePropsReact.addons.classSet is deprecated; use a module such as classnames instead.
React.addons.classSetReact.addons.cloneWithProps calls can be migrated to React.cloneElement, merging style and className manually if desired.
React.addons.cloneWithPropsReact.cloneElement