React 16 depends on the collection types Map and Set. If you support older browsers and devices which may not yet provide these natively (eg <IE11), consider including a global polyfill in your bundled application, such as core-js or babel-polyfill.
・Remove old internal abstractions that didn’t age well and hindered internal changes. ・Let us ship some of the most requested features like returning arrays from render, recovering from component errors, and readable component stack traces for every error. ・Enable us to start experimenting with asynchronous rendering of components for better perceived performance.
This initial React 16.0 release is mostly focused on compatibility with existing apps. It does not enable asynchronous rendering yet. We will introduce an opt-in to the async mode later during React 16.x. We don’t expect React 16.0 to make your apps significantly faster or slower, but we’d love to know if you see improvements or regressions.
・This is a complete rewrite of React but we expect it to work with your existing code. If you fixed all deprecation warnings introduced in 15.x, the 16 beta should work for you. ・Third party libraries that relied on deprecated or unsupported APIs may need updates to work correctly with this new release. Now is a good time to file issues against libraries that have problems. (And tell us if we broke something!) ・We are particularly interested in hearing about performance differences you notice between 15.x and 16.x. We don’t expect any massive changes but would love to know about improvements or regressions. Please report them here! ・The server renderer has been completely rewritten, and now offers a streaming mode (it’s currently exposed via react-dom/node-stream). Server rendering does not use markup validation anymore, and instead tries its best to attach to existing DOM, warning about inconsistencies. This server renderer code is still very new, so it is likely to have issues. Please report them. ・React Native follows a different release cycle and will update to the beta in a future release. (It’s already using an alpha release but not yet using Fiber.)
・Previously, runtime errors used to put React into a broken state and produce cryptic errors. React 16 fixes this by introducing a special kind of components called “error boundaries”. Error boundaries can catch runtime errors in a component tree, log them, and display a fallback UI instead. ・If there is an uncaught error in a component, and there is no error boundary up in the tree, the whole component tree will be unmounted. This helps avoid very nasty bugs where the UI has been corrupted due to an error, but it means that you need to add a few error boundaries to your app to handle the errors gracefully. ・React 15 had a very limited undocumented support for error boundaries with a different method name. It used to be called unstable_handleError, but has been renamed to componentDidCatch.
・setState: ・Calling setState with null no longer triggers an update. This allows you to decide in an updater function if you want to re-render. ・Calling setState directly in render always causes an update. This was not previously the case. Regardless, you should not be calling setState from render. ・setState callback (second argument) now fires immediately after componentDidMount / componentDidUpdate instead of after all components have rendered. ・When replacing <A /> with <B />, B.componentWillMount now always happens before A.componentWillUnmount. Previously, A.componentWillUnmount could fire first in some cases. ・Previously, changing the ref to a component would always detach the ref before that component’s render is called. Now, we change the ref later, when applying the changes to the DOM. ・It is not safe to re-render into a container that was modified by something other than React. This worked previously in some cases but was never supported. Now an explicit error will be thrown. Instead you should clean up your component trees using ReactDOM.unmountComponentAtNode.
componentDidUpdate lifecycle no longer receives prevContext param. (See #8631)
・There is no react/lib/* and react-dom/lib/* anymore. Even in CommonJS environments, React and ReactDOM are precompiled to single files (“flat bundles”). If you previously relied on undocumented React internals, and they don’t work anymore, let us know about your specific case in this issue, and we’ll try to figure out a migration strategy for you. ・There is no react-with-addons.js build anymore. All compatible addons are published separately on npm, and have single-file browser versions if you need them. ・The names and paths to the single-file browser builds have changed to emphasize the difference between development and production builds. For example: ・react/dist/react.js → react/umd/react.development.js ・react/dist/react.min.js → react/umd/react.production.min.js ・react-dom/dist/react-dom.js → react-dom/umd/react-dom.development.js ・react-dom/dist/react-dom.min.js → react-dom/umd/react-dom.production.min.js
react-addons-perf will not work in React 16. We may provide similar functionality at some point during 16.x release cycle but it’s not settled yet. You can use Chrome Performance tab for profiling components, and Performance Observer API for aggregating this data programmatically. See this proof of concept.
・The server renderer crashes in production with inline styles. (#10299, fixed by #10300) ・Fixed in 16.0.0-beta.2 ・The server renderer doesn’t yet support returning arrays and strings from components (PR in #10221, needs review). ・The server renderer still renders data-reactid somewhat unnecessarily. (#10306) ・Shallow renderer doesn’t implement unstable_batchedUpdates. (TBD) ・Some popular third party libraries won’t work yet (e.g. Enzyme). ・There is a report that Google crawler can’t render the page using 16 (link). ・In some cases Error: null is reported instead of the real error. (reactjs/react-redux#756 (comment)) ・(Please report more issues in this thread.)