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.
Summary
This adds support for React 19 to all Gatsby packages, while maintaining support for React 18.
This is not a breaking change.
All packages' peer dependencies on
reactandreact-domhave been extended from^18.0.0to^18.0.0 || ^19.0.0.All existing stable Gatsby functionality is intended to work with React 19.
Upgrade Guide
To upgrade to React 19, first upgrade
gatsbyand all yourgatsby-*dependencies to the latest version. Then, follow the React 19 upgrade guide. No other changes are required.Please note:
(TODO call out the new global error handling stuff)
Implementation
This PR configures CI to run the existing
development-runtimeandproduction-runtimee2e test suites against both React 18 and 19.fix(gatsby-plugin-image): work around a regression in React 19 core
There is an undocumented change in behaviour in React 19: facebook/react#31660. Basically, in previous versions, an unchanged
dangerouslySetInnerHTML.__htmlwould not result in a re-render, but in React 19 referential equality of thedangerouslySetInnerHTMLobject is used instead.The
gatsby-plugin-imageimplementation fundamentally depends on the previous behaviour, so that our owninnerHTMLupdates do not get clobbered by a reset to thisdangerouslySetInnerHTMLplaceholer value.As a workaround, this commit memoizes the object with
useMemo().This is safe for React 18 as well.
fix: replace usages of
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED😶There was one use of
React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED?.ReactDebugCurrentFrame?.getCurrentStack(). React 19 introducedReact.captureOwnerStack()which we'll now use instead if available.(TODO describe the react-refresh / partial hydration stuff)