Skip to content

Releases: facebook/react

[email protected] (Oct 11, 2024)

11 Oct 13:32
0911120
Compare
Choose a tag to compare

This release only contains eslint-plugin-react-hooks. Notably, new violations and support for ESLint v9 were added.

eslint-plugin-react-hooks

  • New Violations: Component names now need to start with an uppercase letter instead of a non-lowercase letter. This means _Button or _component are no longer valid. (@kassens) in #25162
    For example, in
    function _Component() {
      useState()
      ^^^^^^^^ A React Hook "useState" is called in function "_Component" which is neither a Component nor a custom React Hook function.
    }
    _Component should be renamed to Component.

18.3.1 (April 26, 2024)

26 Apr 19:53
f1338f8
Compare
Choose a tag to compare
  • Export act from react f1338f

18.3.0 (April 25, 2024)

26 Apr 19:48
8a015b6
Compare
Choose a tag to compare

This release is identical to 18.2 but adds warnings for deprecated APIs and other changes that are needed for React 19.

Read the React 19 Upgrade Guide for more info.

React

  • Allow writing to this.refs to support string ref codemod 909071
  • Warn for deprecated findDOMNode outside StrictMode c3b283
  • Warn for deprecated test-utils methods d4ea75
  • Warn for deprecated Legacy Context outside StrictMode 415ee0
  • Warn for deprecated string refs outside StrictMode #25383
  • Warn for deprecated defaultProps for function components #25699
  • Warn when spreading key #25697
  • Warn when using act from test-utils d4ea75

React DOM

  • Warn for deprecated unmountComponentAtNode 8a015b
  • Warn for deprecated renderToStaticNodeStream #28874

18.2.0 (June 14, 2022)

14 Jun 19:54
9e3b772
Compare
Choose a tag to compare

React DOM

  • Provide a component stack as a second argument to onRecoverableError. (@gnoff in #24591)
  • Fix hydrating into document causing a blank page on mismatch. (@gnoff in #24523)
  • Fix false positive hydration errors with Suspense. (@gnoff in #24480 and @acdlite in #24532)
  • Fix ignored setState in Safari when adding an iframe. (@gaearon in #24459)

React DOM Server

  • Pass information about server errors to the client. (@salazarm and @gnoff in #24551 and #24591)
  • Allow to provide a reason when aborting the HTML stream. (@gnoff in #24680)
  • Eliminate extraneous text separators in the HTML where possible. (@gnoff in #24630)
  • Disallow complex children inside <title> elements to match the browser constraints. (@gnoff in #24679)
  • Fix buffering in some worker environments by explicitly setting highWaterMark to 0. (@jplhomer in #24641)

Server Components (Experimental)

  • Add support for useId() inside Server Components. (@gnoff) in #24172

18.1.0 (April 26, 2022)

26 Apr 21:15
22edb9f
Compare
Choose a tag to compare

React DOM

  • Fix the false positive warning about react-dom/client when using UMD bundle. (@alireza-molaee in #24274)
  • Fix suppressHydrationWarning to work in production too. (@gaearon in #24271)
  • Fix componentWillUnmount firing twice inside of Suspense. (@acdlite in #24308)
  • Fix some transition updates being ignored. (@acdlite in #24353)
  • Fix useDeferredValue causing an infinite loop when passed an unmemoized value. (@acdlite in #24247)
  • Fix throttling of revealing Suspense fallbacks. (@sunderls in #24253)
  • Fix an inconsistency in whether the props object is the same between renders. (@Andarist and @acdlite in #24421)
  • Fix a missing warning about a setState loop in useEffect. (@gaearon in #24298)
  • Fix a spurious hydration error. (@gnoff in #24404)
  • Warn when calling setState in useInsertionEffect. (@gaearon in #24295)
  • Ensure the reason for hydration errors is always displayed. (@gaearon in #24276)

React DOM Server

  • Fix escaping for the bootstrapScriptContent contents. (@gnoff in #24385)
  • Significantly improve performance of renderToPipeableStream. (@gnoff in #24291)

ESLint Plugin: React Hooks

  • Fix false positive errors with a large number of branches. (@scyron6 in #24287)
  • Don't consider a known dependency stable when the variable is reassigned. (@afzalsayed96 in #24343)

Use Subscription

  • Replace the implementation with the use-sync-external-store shim. (@gaearon in #24289)

18.0.0 (March 29, 2022)

29 Mar 17:22
Compare
Choose a tag to compare

Below is a list of all new features, APIs, deprecations, and breaking changes.
Read React 18 release post and React 18 upgrade guide for more information.

New Features

React

  • useId is a new hook for generating unique IDs on both the client and server, while avoiding hydration mismatches. It is primarily useful for component libraries integrating with accessibility APIs that require unique IDs. This solves an issue that already exists in React 17 and below, but it’s even more important in React 18 because of how the new streaming server renderer delivers HTML out-of-order.
  • startTransition and useTransition let you mark some state updates as not urgent. Other state updates are considered urgent by default. React will allow urgent state updates (for example, updating a text input) to interrupt non-urgent state updates (for example, rendering a list of search results).
  • useDeferredValue lets you defer re-rendering a non-urgent part of the tree. It is similar to debouncing, but has a few advantages compared to it. There is no fixed time delay, so React will attempt the deferred render right after the first render is reflected on the screen. The deferred render is interruptible and doesn't block user input.
  • useSyncExternalStore is a new hook that allows external stores to support concurrent reads by forcing updates to the store to be synchronous. It removes the need for useEffect when implementing subscriptions to external data sources, and is recommended for any library that integrates with state external to React.
  • useInsertionEffect is a new hook that allows CSS-in-JS libraries to address performance issues of injecting styles in render. Unless you’ve already built a CSS-in-JS library we don’t expect you to ever use this. This hook will run after the DOM is mutated, but before layout effects read the new layout. This solves an issue that already exists in React 17 and below, but is even more important in React 18 because React yields to the browser during concurrent rendering, giving it a chance to recalculate layout.

React DOM Client

These new APIs are now exported from react-dom/client:

  • createRoot: New method to create a root to render or unmount. Use it instead of ReactDOM.render. New features in React 18 don't work without it.
  • hydrateRoot: New method to hydrate a server rendered application. Use it instead of ReactDOM.hydrate in conjunction with the new React DOM Server APIs. New features in React 18 don't work without it.

Both createRoot and hydrateRoot accept a new option called onRecoverableError in case you want to be notified when React recovers from errors during rendering or hydration for logging. By default, React will use reportError, or console.error in the older browsers.

React DOM Server

These new APIs are now exported from react-dom/server and have full support for streaming Suspense on the server:

  • renderToPipeableStream: for streaming in Node environments.
  • renderToReadableStream: for modern edge runtime environments, such as Deno and Cloudflare workers.

The existing renderToString method keeps working but is discouraged.

Deprecations

  • react-dom: ReactDOM.render has been deprecated. Using it will warn and run your app in React 17 mode.
  • react-dom: ReactDOM.hydrate has been deprecated. Using it will warn and run your app in React 17 mode.
  • react-dom: ReactDOM.unmountComponentAtNode has been deprecated.
  • react-dom: ReactDOM.renderSubtreeIntoContainer has been deprecated.
  • react-dom/server: ReactDOMServer.renderToNodeStream has been deprecated.

Breaking Changes

React

  • Automatic batching: This release introduces a performance improvement that changes to the way React batches updates to do more batching automatically. See Automatic batching for fewer renders in React 18 for more info. In the rare case that you need to opt out, wrap the state update in flushSync.
  • Stricter Strict Mode: In the future, React will provide a feature that lets components preserve state between unmounts. To prepare for it, React 18 introduces a new development-only check to Strict Mode. React will automatically unmount and remount every component, whenever a component mounts for the first time, restoring the previous state on the second mount. If this breaks your app, consider removing Strict Mode until you can fix the components to be resilient to remounting with existing state.
  • Consistent useEffect timing: React now always synchronously flushes effect functions if the update was triggered during a discrete user input event such as a click or a keydown event. Previously, the behavior wasn't always predictable or consistent.
  • Stricter hydration errors: Hydration mismatches due to missing or extra text content are now treated like errors instead of warnings. React will no longer attempt to "patch up" individual nodes by inserting or deleting a node on the client in an attempt to match the server markup, and will revert to client rendering up to the closest <Suspense> boundary in the tree. This ensures the hydrated tree is consistent and avoids potential privacy and security holes that can be caused by hydration mismatches.
  • Suspense trees are always consistent: If a component suspends before it's fully added to the tree, React will not add it to the tree in an incomplete state or fire its effects. Instead, React will throw away the new tree completely, wait for the asynchronous operation to finish, and then retry rendering again from scratch. React will render the retry attempt concurrently, and without blocking the browser.
  • Layout Effects with Suspense: When a tree re-suspends and reverts to a fallback, React will now clean up layout effects, and then re-create them when the content inside the boundary is shown again. This fixes an issue which prevented component libraries from correctly measuring layout when used with Suspense.
  • New JS Environment Requirements: React now depends on modern browsers features including Promise, Symbol, and Object.assign. If you support older browsers and devices such as Internet Explorer which do not provide modern browser features natively or have non-compliant implementations, consider including a global polyfill in your bundled application.

Scheduler (Experimental)

  • Remove unstable scheduler/tracing API

Notable Changes

React

  • Components can now render undefined: React no longer throws if you return undefined from a component. This makes the allowed component return values consistent with values that are allowed in the middle of a component tree. We suggest to use a linter to prevent mistakes like forgetting a return statement before JSX.
  • In tests, act warnings are now opt-in: If you're running end-to-end tests, the act warnings are unnecessary. We've introduced an opt-in mechanism so you can enable them only for unit tests where they are useful and beneficial.
  • No warning about setState on unmounted components: Previously, React warned about memory leaks when you call setState on an unmounted component. This warning was added for subscriptions, but people primarily run into it in scenarios where setting state is fine, and workarounds make the code worse. We've removed this warning.
  • No suppression of console logs: When you use Strict Mode, React renders each component twice to help you find unexpected side effects. In React 17, we've suppressed console logs for one of the two renders to make the logs easier to read. In response to community feedback about this being confusing, we've removed the suppression. Instead, if you have React DevTools installed, the second log's renders will be displayed in grey, and there will be an option (off by default) to suppress them completely.
  • Improved memory usage: React now cleans up more internal fields on unmount, making the impact from unfixed memory leaks that may exist in your application code less severe.

React DOM Server

  • renderToString: Will no longer error when suspending on the server. Instead, it will emit the fallback HTML for the closest <Suspense> boundary and then retry rendering the same content on the client. It is still recommended that you switch to a streaming API like renderToPipeableStream or renderToReadableStream instead.
  • renderToStaticMarkup: Will no longer error when suspending on the server. Instead, it will emit the fallback HTML for the closest <Suspense> boundary and retry rendering on the client.

All Changes

React

Read more

17.0.2 (March 22, 2021)

22 Mar 22:00
Compare
Choose a tag to compare

17.0.1 (October 22, 2020)

22 Mar 21:59
Compare
Choose a tag to compare

React DOM

17.0.0 (October 20, 2020)

20 Oct 20:45
Compare
Choose a tag to compare

Today, we are releasing React 17!

Learn more about React 17 and how to update to it on the official React blog.

React

React DOM

  • Delegate events to roots instead of document. (@trueadm in #18195 and others)
  • Clean up all effects before running any next effects. (@bvaughn in #17947)
  • Run useEffect cleanup functions asynchronously. (@bvaughn in #17925)
  • Use browser focusin and focusout for onFocus and onBlur. (@trueadm in #19186)
  • Make all Capture events use the browser capture phase. (@trueadm in #19221)
  • Don't emulate bubbling of the onScroll event. (@gaearon in #19464)
  • Throw if forwardRef or memo component returns undefined. (@gaearon in #19550)
  • Remove event pooling. (@trueadm in #18969)
  • Stop exposing internals that won’t be needed by React Native Web. (@necolas in #18483)
  • Attach all known event listeners when the root mounts. (@gaearon in #19659)
  • Disable console in the second render pass of DEV mode double render. (@sebmarkbage in #18547)
  • Deprecate the undocumented and misleading ReactTestUtils.SimulateNative API. (@gaearon in #13407)
  • Rename private field names used in the internals. (@gaearon in #18377)
  • Don't call User Timing API in development. (@gaearon in #18417)
  • Disable console during the repeated render in Strict Mode. (@sebmarkbage in #18547)
  • In Strict Mode, double-render components without Hooks too. (@eps1lon in #18430)
  • Allow calling ReactDOM.flushSync during lifecycle methods (but warn). (@sebmarkbage in #18759)
  • Add the code property to the keyboard event objects. (@bl00mber in #18287)
  • Add the disableRemotePlayback property for video elements. (@tombrowndev in #18619)
  • Add the enterKeyHint property for input elements. (@eps1lon in #18634)
  • Warn when no value is provided to <Context.Provider>. (@charlie1404 in #19054)
  • Warn when memo or forwardRef components return undefined. (@bvaughn in #19550)
  • Improve the error message for invalid updates. (@JoviDeCroock in #18316)
  • Exclude forwardRef and memo from stack frames. (@sebmarkbage in #18559)
  • Improve the error message when switching between controlled and uncontrolled inputs. (@vcarl in #17070)
  • Keep onTouchStart, onTouchMove, and onWheel passive. (@gaearon in #19654)
  • Fix setState hanging in development inside a closed iframe. (@gaearon in #19220)
  • Fix rendering bailout for lazy components with defaultProps. (@jddxf in #18539)
  • Fix a false positive warning when dangerouslySetInnerHTML is undefined. (@eps1lon in #18676)
  • Fix Test Utils with non-standard require implementation. (@just-boris in #18632)
  • Fix onBeforeInput reporting an incorrect event.type. (@eps1lon in #19561)
  • Fix event.relatedTarget reported as undefined in Firefox. (@claytercek in #19607)
  • Fix "unspecified error" in IE11. (@hemakshis in #19664)
  • Fix rendering into a shadow root. (@Jack-Works in #15894)
  • Fix movementX/Y polyfill with capture events. (@gaearon in #19672)
  • Use delegation for onSubmit and onReset events. (@gaearon in #19333)
  • Improve memory usage. (@trueadm in #18970)

React DOM Server

  • Make useCallback behavior consistent with useMemo for the server renderer. (@alexmckenley in #18783)
  • Fix state leaking when a function component throws. (@pmaccart in #19212)

React Test Renderer

Concurrent Mode (Experimental)

  • Revamp the priority batching heuristics. (@acdlite in #18796)
  • Add the unstable_ prefix before the experimental APIs. (@acdlite in #18825)
  • Remove unstable_discreteUpdates and unstable_flushDiscreteUpdates. (@trueadm in #18825)
  • Remove the timeoutMs argument. (@acdlite in #19703)
  • Disable <div hidden /> prerendering in favor of a different future API. (@acdlite in #18917)
  • Add unstable_expectedLoadTime to Suspense for CPU-bound trees. (@acdlite in #19936)
  • Add an experimental unstable_useOpaqueIdentifier Hook. (@lunaruan in #17322)
  • Add an experimental unstable_startTransition API. (@rickhanlonii in #19696)
  • Using act in the test renderer no longer flushes Suspense fallbacks. (@acdlite in #18596)
  • Use global render timeout for CPU Suspense. (@sebmarkbage in #19643)
  • Clear the existing root content before mounting. (@bvaughn in #18730)
  • Fix a bug with error boundaries. (@acdlite in #18265)
  • Fix a bug causing dropped updates in a suspended tree. (@acdlite in #18384 and #18457)
  • Fix a bug causing dropped render phase updates. (@acdlite in #18537)
  • Fix a bug in Suspens...
Read more

16.14.0 (October 14, 2020)

14 Oct 19:58
Compare
Choose a tag to compare