[Snyk] Upgrade react from 18.3.1 to 19.2.0 #2390
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



Snyk has created this PR to upgrade react from 18.3.1 to 19.2.0.
ℹ️ Keep your dependencies up-to-date. This makes it easier to fix existing vulnerabilities and to more quickly identify and fix newly disclosed vulnerabilities when they affect your project.
The recommended version is 414 versions ahead of your current version.
The recommended version was released 24 days ago.
Release notes
Package name: react
Below is a list of all new features, APIs, and bug fixes.
Read the React 19.2 release post for more information.
New React Features
<Activity>: A new API to hide and restore the UI and internal state of its children.useEffectEventis a React Hook that lets you extract non-reactive logic into an Effect Event.cacheSignal(for RSCs) lets your know when thecache()lifetime is over.New React DOM Features
resume: to resume a prerender to a stream.resumeAndPrerender: to resume a prerender to HTML.resumeToPipeableStream: to resume a prerender to a stream.resumeAndPrerenderToNodeStream: to resume a prerender to HTML.prerenderAPIs to return apostponedstate that can be passed to theresumeAPIs.Notable changes
<ViewTransition>Component. React will batch as much reveals as possible before the first paint while trying to hit popular first-contentful paint metrics.prerender,renderToReadableStream) to server-side-rendering APIs for Node.js:IDs generated by useIdAll Changes
React
<Activity />was developed over many years, starting beforeClassComponent.setState(@ acdlite @ sebmarkbage and many others)%oplaceholder (@ eps1lon #34198)useDeferredValueloop in popstate event (@ acdlite #32821)useDeferredValue(@ acdlite #34376)cacheSignal(@ sebmarkbage #33557)React DOM
:for IDs generated byuseId(@ sebmarkbage, @ eps1lon: #32001, #33342#33099, #33422)nonceto be used on hoistable styles (@ Andarist #32461)React.useinsideReact.lazy-ed Component (@ hi-ogawa #33941)progressiveChunkSizeoption for server-side-rendering APIs (@ sebmarkbage #33027)React Server Components
<img>and<link>using hints before they're rendered (@ sebmarkbage #34604)filterStackFrame(@ eps1lon #33707)React Reconciler
on*handlers to account for upcoming experimental APIs[email protected]
Note: Version 6.0.0 was mistakenly released and immediately deprecated and untagged on npm. This is the first official 6.x major release and includes breaking changes.
recommendedpreset. Legacy config moved torecommended-legacy. (@ michaelfaith in #32457)usewithin try/catch blocks. (@ poteto in #34040)useEffectEventfunctions in arbitrary closures. (@ jbrown215 in #33544)React.useEffectin addition touseEffectin rules-of-hooks. (@ Ayc0 in #34076)react-hookssettings config option that to acceptadditionalEffectHooksthat are used across exhaustive-deps and rules-of-hooks rules. (@ jbrown215) in #34497React
Owner Stack
An Owner Stack is a string representing the components that are directly responsible for rendering a particular component. You can log Owner Stacks when debugging or use Owner Stacks to enhance error overlays or other development tools. Owner Stacks are only available in development builds. Component Stacks in production are unchanged.
#32538, #32529, #32538
React
useIdto use valid CSS selectors, changing format from:r123:to«r123». #32001React DOM
hrefattribute is an empty string #31783getHoistableRoot()didn’t work properly when the container was a Document #32321<!-- -->) as a DOM container. #32250<script>and<template>tags to be nested within<select>tags. #31837use-sync-external-store
exportsfield topackage.jsonforuse-sync-external-storeto support various entrypoints. #25231React Server Components
unstable_prerender, a new experimental API for prerendering React Server Components on the server #31724registerServerReferencein client builds to handle server references in different environments. #32534Below is a list of all new features, APIs, deprecations, and breaking changes. Read React 19 release post and React 19 upgrade guide for more information.
New Features
React
startTransitioncan now accept async functions. Functions passed tostartTransitionare called “Actions”. A given Transition can include one or more Actions which update state in the background and update the UI with one commit. In addition to updating state, Actions can now perform side effects including async requests, and the Action will wait for the work to finish before finishing the Transition. This feature allows Transitions to include side effects likefetch()in the pending state, and provides support for error handling, and optimistic updates.useActionState: is a new hook to order Actions inside of a Transition with access to the state of the action, and the pending state. It accepts a reducer that can call Actions, and the initial state used for first render. It also accepts an optional string that is used if the action is passed to a formactionprop to support progressive enhancement in forms.useOptimistic: is a new hook to update state while a Transition is in progress. It returns the state, and a set function that can be called inside a transition to “optimistically” update the state to expected final value immediately while the Transition completes in the background. When the transition finishes, the state is updated to the new value.use: is a new API that allows reading resources in render. In React 19,useaccepts a promise or Context. If provided a promise,usewill suspend until a value is resolved.usecan only be used in render but can be called conditionally.refas a prop: Refs can now be used as props, removing the need forforwardRef.React DOM Client
<form> actionprop: Form Actions allow you to manage forms automatically and integrate withuseFormStatus. When a<form> actionsucceeds, React will automatically reset the form for uncontrolled components. The form can be reset manually with the newrequestFormResetAPI.<button> and <input> formActionprop: Actions can be passed to theformActionprop to configure form submission behavior. This allows using different Actions depending on the input.useFormStatus: is a new hook that provides the status of the parent<form> action, as if the form was a Context provider. The hook returns the values:pending,data,method, andaction.<head>section of the document.<head>on the client before revealing the content of a Suspense boundary that depends on that stylesheet.preinit,preload,prefetchDNS, andpreconnectAPIs to optimize initial page loads by moving discovery of additional resources like fonts out of stylesheet loading. They can also be used to prefetch resources used by an anticipated navigation.React DOM Server
prerenderandprerenderToNodeStreamAPIs for static site generation. They are designed to work with streaming environments like Node.js Streams and Web Streams. UnlikerenderToString, they wait for data to load for HTML generation.React Server Components
Deprecations
element.refaccess: React 19 supports ref as a prop, so we’re deprecatingelement.refin favor ofelement.props.ref. Accessing will result in a warning.react-test-renderer: In React 19, react-test-renderer logs a deprecation warning and has switched to concurrent rendering for web usage. We recommend migrating your tests to @ testinglibrary.com/docs/react-testing-library/intro/) or @ testingesting-library.com/docs/react-native-testing-library/intro)Breaking Changes
React 19 brings in a number of breaking changes, including the removals of long-deprecated APIs. We recommend first upgrading to
18.3.1, where we've added additional deprecation warnings. Check out the upgrade guide for more details and guidance on codemodding.React
onUncaughtErrorandonCaughtErrormethods tocreateRootandhydrateRootto customize this error handling.propTypes: UsingpropTypeswill now be silently ignored. If required, we recommend migrating to TypeScript or another type-checking solution.defaultPropsfor functions: ES6 default parameters can be used in place. Class components continue to supportdefaultPropssince there is no ES6 alternative.contextTypesandgetChildContext: Legacy Context for class components has been removed in favor of thecontextTypeAPI.React.createFactory: Now that JSX is broadly supported, allcreateFactoryusage can be migrated to JSX components.react-test-renderer/shallow: This has been a re-export of react-shallow-renderer since React 18. If needed, you can continue to use the third-party package directly. We recommend using @ testinglibrary.com/docs/react-testing-library/intro/) or @ testingesting-library.com/docs/react-native-testing-library/intro) instead.React DOM
react-dom/test-utils: We’ve movedactfromreact-dom/test-utilsto react. All other utilities have been removed.ReactDOM.render,ReactDOM.hydrate: These have been removed in favor of the concurrent equivalents:ReactDOM.createRootandReactDOM.hydrateRoot.unmountComponentAtNode: Removed in favor ofroot.unmount().ReactDOM.findDOMNode: You can replaceReactDOM.findDOMNodewith DOM Refs.Notable Changes
React
<Context>as a provider: You can now render<Context>as a provider instead of<Context.Provider>.useDeferredValueinitial value argument: When provided,useDeferredValuewill return the initial value for the initial render of a component, then schedule a re-render in the background with thedeferredValuereturned.useMemoanduseCallbackwill now reuse the memoized results from the first render, during the second render. Additionally, StrictMode will now double-invoke ref callback functions on initial mount.React DOM
TypeScript Changes
The most common changes can be codemodded with
npx types-react-codemod@latest preset-19 ./path-to-your-react-ts-files.ReactChild(replacement:React.ReactElement | number | string)ReactFragment(replacement:Iterable<React.ReactNode>)ReactNodeArray(replacement:ReadonlyArray<React.ReactNode>)ReactText(replacement:number | string)VoidFunctionComponent(re...