Upgrading react 0.11 to 0.12
Breaking0.11.2 → 0.12.2Breaking8Deprecated11New7Changed7Fixed9Other1
BreakingUpgrade verdict
8 breaking changes.
In plain terms
- Default values for props are now fixed when the element is created, not when it is mounted.
- An internal-only API is gone; the developer tools no longer rely on it.
- You can no longer call a component function directly; wrap it in a factory, or just use JSX which does it for you.
- Passing scrollLeft or scrollTop as props no longer works; set them on the DOM node instead.
Must act Top 5 of 19 that need code or config changes
Installs 34 packages in all (was 9).
What you must change
Breaking8
Moves default prop resolution to element creation time instead of mount time, making defaults effectively static.
getDefaultPropsRemoves
React.__internals, which was exposed for DevTools that no longer needs access.React.__internalsComposite component functions can no longer be called directly and must be wrapped with
React.createFactory first, which JSX handles automatically.React.createFactoryRemoves scrollLeft and scrollTop props, which should not be specified as props.
scrollLeftscrollTopReact.addons.update now uses assign instead of copyProperties with hasOwnProperty checks, so prototype properties are no longer updated correctly.
React.addons.updateassigncopyPropertieshasOwnPropertyJSX no longer transforms to simple function calls.
Moves
key and ref off the props object so they are now accessible on the element directly.keyrefpropsEnforces that lower case JSX tag names are always HTML tags and upper case tag names are always composite components.
Deprecations to plan for
Deprecated11
Deprecates
React.renderComponent in favor of React.render.React.renderComponentReact.renderDeprecates
React.renderComponentToString in favor of React.renderToString.React.renderComponentToStringReact.renderToStringDeprecates
React.renderComponentToStaticMarkup in favor of React.renderToStaticMarkup.React.renderComponentToStaticMarkupReact.renderToStaticMarkupDeprecates
React.isValidComponent in favor of React.isValidElement.React.isValidComponentReact.isValidElementDeprecates
React.PropTypes.component in favor of React.PropTypes.element.React.PropTypes.componentReact.PropTypes.elementDeprecates
React.PropTypes.renderable in favor of React.PropTypes.node.React.PropTypes.renderableReact.PropTypes.nodeDeprecates
React.isValidClass.React.isValidClassDeprecates
instance.transferPropsTo.instance.transferPropsToDeprecates returning
false from event handlers to preventDefault.preventDefaultDeprecates convenience constructor usage as a function; wrap with
React.createFactory instead.React.createFactoryDeprecates use of
key={null} to assign implicit keys.key