Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support React 19 #10745

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion admin/test-bad-package/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {version as ReactVersion} from 'react';
import {version as ReactDOMVersion} from 'react-dom';

export function TestComponent() {
const expectedVersion = 18;
const expectedVersion = 19;
if (!ReactVersion.startsWith(`${expectedVersion}`)) {
throw new Error(
`'test-bad-package/README.mdx' is rendered with bad React version: ${ReactVersion}`,
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@
"@types/lodash": "^4.14.197",
"@types/node": "^18.16.19",
"@types/prompts": "^2.4.4",
"@types/react": "^18.2.15",
"@types/react": "^19.0.0",
"@types/react-dev-utils": "^9.0.11",
"@types/react-test-renderer": "^18.0.0",
"@types/react-test-renderer": "^19.0.0",
"@types/semver": "^7.5.0",
"@types/shelljs": "^0.8.12",
"@typescript-eslint/eslint-plugin": "^5.62.0",
Expand Down Expand Up @@ -113,10 +113,10 @@
"lockfile-lint": "^4.14.0",
"npm-run-all": "^4.1.5",
"prettier": "^2.8.8",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-helmet-async": "^1.3.0",
"react-test-renderer": "^18.0.0",
"react-test-renderer": "^19.0.0",
"rimraf": "^3.0.2",
"sharp": "^0.32.3",
"strip-ansi": "^6.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"@mdx-js/react": "^3.0.0",
"clsx": "^2.0.0",
"prism-react-renderer": "^2.3.0",
"react": "^18.0.0",
"react-dom": "^18.0.0"
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "3.6.3",
Expand Down
4 changes: 2 additions & 2 deletions packages/create-docusaurus/templates/classic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"@mdx-js/react": "^3.0.0",
"clsx": "^2.0.0",
"prism-react-renderer": "^2.3.0",
"react": "^18.0.0",
"react-dom": "^18.0.0"
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "3.6.3",
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-mdx-loader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
"unist-util-remove-position": "^5.0.0"
},
"peerDependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0"
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"engines": {
"node": ">=18.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-module-type-aliases/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"dependencies": {
"@docusaurus/types": "3.6.3",
"@types/history": "^4.7.11",
"@types/react": "*",
"@types/react": "^19.0.0",
"@types/react-router-config": "*",
"@types/react-router-dom": "*",
"react-helmet-async": "*",
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-plugin-client-redirects/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"@docusaurus/types": "3.6.3"
},
"peerDependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0"
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"engines": {
"node": ">=18.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-plugin-content-blog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
},
"peerDependencies": {
"@docusaurus/plugin-content-docs": "*",
"react": "^18.0.0",
"react-dom": "^18.0.0"
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"engines": {
"node": ">=18.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-plugin-content-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
"shelljs": "^0.8.5"
},
"peerDependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0"
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"engines": {
"node": ">=18.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-plugin-content-pages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"webpack": "^5.88.1"
},
"peerDependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0"
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"engines": {
"node": ">=18.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-plugin-debug/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"tslib": "^2.6.0"
},
"peerDependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0"
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"engines": {
"node": ">=18.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-plugin-google-analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"tslib": "^2.6.0"
},
"peerDependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0"
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"engines": {
"node": ">=18.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-plugin-google-gtag/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"tslib": "^2.6.0"
},
"peerDependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0"
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"engines": {
"node": ">=18.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-plugin-google-tag-manager/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"tslib": "^2.6.0"
},
"peerDependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0"
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"engines": {
"node": ">=18.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-plugin-ideal-image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
},
"peerDependencies": {
"jimp": "*",
"react": "^18.0.0",
"react-dom": "^18.0.0"
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"peerDependenciesMeta": {
"jimp": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ export default function IdealImage(props: Props): ReactNode {

return (
<ReactIdealImage
// @ts-expect-error: quick fix for React >= 19 not applying defaultProps
icons={ReactIdealImage.defaultProps.icons}
// @ts-expect-error: quick fix for React >= 19 not applying defaultProps
theme={ReactIdealImage.defaultProps.theme}
{...propsRest}
height={img.src.height ?? 100}
width={img.src.width ?? 100}
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-plugin-pwa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@
"fs-extra": "^11.1.0"
},
"peerDependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0"
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"engines": {
"node": ">=18.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-plugin-rsdoctor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"tslib": "^2.6.0"
},
"peerDependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0"
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"engines": {
"node": ">=18.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-plugin-sitemap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"@total-typescript/shoehorn": "^0.1.2"
},
"peerDependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0"
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"engines": {
"node": ">=18.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-plugin-svgr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"webpack": "^5.88.1"
},
"peerDependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0"
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"engines": {
"node": ">=18.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-plugin-vercel-analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"tslib": "^2.6.0"
},
"peerDependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0"
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"engines": {
"node": ">=18.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-preset-classic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"@docusaurus/types": "3.6.3"
},
"peerDependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0"
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"engines": {
"node": ">=18.0"
Expand Down
6 changes: 3 additions & 3 deletions packages/docusaurus-theme-classic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@
"@types/prismjs": "^1.26.0",
"@types/rtlcss": "^3.5.1",
"fs-extra": "^11.1.1",
"react-test-renderer": "^18.0.0",
"react-test-renderer": "^19.0.0",
"utility-types": "^3.10.0"
},
"peerDependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0"
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"engines": {
"node": ">=18.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-theme-common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
},
"peerDependencies": {
"@docusaurus/plugin-content-docs": "*",
"react": "^18.0.0",
"react-dom": "^18.0.0"
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"engines": {
"node": ">=18.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {useMutationObserver} from './useMutationObserver';
// Callback fires when the "hidden" attribute of a tabpanel changes
// See https://github.com/facebook/docusaurus/pull/7485
function useTabBecameVisibleCallback(
codeBlockRef: RefObject<HTMLPreElement>,
codeBlockRef: RefObject<HTMLPreElement | null>,
callback: () => void,
) {
const [hiddenTabElement, setHiddenTabElement] = useState<
Expand Down Expand Up @@ -53,7 +53,7 @@ function useTabBecameVisibleCallback(
}

export function useCodeWordWrap(): {
readonly codeBlockRef: RefObject<HTMLPreElement>;
readonly codeBlockRef: RefObject<HTMLPreElement | null>;
readonly isEnabled: boolean;
readonly isCodeScrollable: boolean;
readonly toggle: () => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function useEvent<T extends (...args: never[]) => unknown>(
* Gets `value` from the last render.
*/
export function usePrevious<T>(value: T): T | undefined {
const ref = useRef<T>();
const ref = useRef<T>(undefined);

useIsomorphicLayoutEffect(() => {
ref.current = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function useSkipToContent(): {
* so that keyboard navigators can instantly interact with the link and jump
* to content.
*/
containerRef: React.RefObject<HTMLDivElement>;
containerRef: React.RefObject<HTMLDivElement | null>;
/**
* Callback fired when the skip to content link has been clicked.
* It will programmatically focus the main content.
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-theme-live-codeblock/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
"@types/buble": "^0.20.1"
},
"peerDependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0"
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"engines": {
"node": ">=18.0"
Expand Down
6 changes: 3 additions & 3 deletions packages/docusaurus-theme-mermaid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
"tslib": "^2.6.0"
},
"devDependencies": {
"react-test-renderer": "^18.0.0"
"react-test-renderer": "^19.0.0"
},
"peerDependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0"
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"engines": {
"node": ">=18.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-theme-search-algolia/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
"@docusaurus/module-type-aliases": "3.6.3"
},
"peerDependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0"
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"engines": {
"node": ">=18.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ function DocSearch({
})),
).current;

// @ts-expect-error: TODO fix lib issue after React 19, using JSX.Element
const resultsFooterComponent: DocSearchProps['resultsFooterComponent'] =
useMemo(
() =>
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"webpack-merge": "^5.9.0"
},
"peerDependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0"
"react": "^19.0.0",
"react-dom": "^19.0.0"
}
}
6 changes: 3 additions & 3 deletions packages/docusaurus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,14 @@
"@types/serve-handler": "^6.1.4",
"@types/update-notifier": "^6.0.4",
"@types/webpack-bundle-analyzer": "^4.7.0",
"react-test-renderer": "^18.0.0",
"react-test-renderer": "^19.0.0",
"tmp-promise": "^3.0.3",
"tree-node-cli": "^1.6.0"
},
"peerDependencies": {
"@mdx-js/react": "^3.0.0",
"react": "^18.0.0",
"react-dom": "^18.0.0"
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"engines": {
"node": ">=18.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus/src/client/exports/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function Link(

const IOSupported = ExecutionEnvironment.canUseIntersectionObserver;

const ioRef = useRef<IntersectionObserver>();
const ioRef = useRef<IntersectionObserver>(undefined);

const handleRef = (el: HTMLAnchorElement | null) => {
innerRef.current = el;
Expand Down
Loading
Loading