Skip to content

Commit 52b2f25

Browse files
committed
feat: add React 19 support (#2941)
Co-authored-by: Alexander Nanberg
1 parent 8d1946c commit 52b2f25

File tree

19 files changed

+232
-116
lines changed

19 files changed

+232
-116
lines changed

.changeset/curly-pugs-hope.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@react-pdf/reconciler": minor
3+
"@react-pdf/renderer": minor
4+
---
5+
6+
feat: add React 19 support

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
matrix:
2323
# We aim to test all maintained LTS versions of Node.js as well as the latest stable version
2424
node_version: [18, 20, 21]
25-
react_version: [16, 17, 18]
25+
react_version: [16, 17, 18, 19]
2626

2727
steps:
2828
- name: Checkout

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"version": "independent",
3-
"packages": ["packages/*", "e2e/*"],
3+
"packages": ["packages/*", "packages/examples/*", "e2e/*"],
44
"npmClient": "yarn"
55
}

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,11 @@
6565
"react": "^18.2.0",
6666
"react-16": "npm:react@^16.8.0",
6767
"react-17": "npm:react@^17.0.0",
68+
"react-19": "npm:[email protected]",
6869
"react-dom": "^18.2.0",
6970
"react-dom-16": "npm:react-dom@^16.8.0",
7071
"react-dom-17": "npm:react-dom@^17.0.0",
72+
"react-dom-19": "npm:[email protected]",
7173
"rimraf": "^2.6.3",
7274
"rollup": "^4.9.0",
7375
"rollup-plugin-copy": "^3.5.0",

packages/examples/next-14/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"private": true,
55
"scripts": {
66
"dev": "next dev",
7-
"build": "next build",
87
"start": "next start",
98
"lint": "next lint"
109
},

packages/examples/next-15/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"private": true,
55
"scripts": {
66
"dev": "next dev",
7-
"build": "next build",
87
"start": "next start",
98
"lint": "next lint"
109
},

packages/examples/vite/package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,21 @@
77
"homepage": "https://github.com/diegomura/react-pdf#readme",
88
"repository": "[email protected]:diegomura/react-pdf.git",
99
"scripts": {
10-
"dev": "vite ./src --open"
10+
"dev": "vite ./src --open",
11+
"build:site": "vite build ./src"
1112
},
1213
"dependencies": {
1314
"@react-pdf/renderer": "^4.0.2"
1415
},
16+
"peerDependencies": {
17+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
18+
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
19+
},
1520
"devDependencies": {
1621
"@vitejs/plugin-react": "^4.2.1",
1722
"autoprefixer": "^10.4.20",
1823
"postcss": "^8.4.47",
1924
"tailwindcss": "^3.4.12",
2025
"vite": "^5.0.11"
21-
},
22-
"peerDependencies": {
23-
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
24-
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
2526
}
2627
}

packages/examples/vite/src/examples/svg/index.jsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import ReactPDF, { Document, Page, StyleSheet } from '@react-pdf/renderer';
2+
import { Document, Page, StyleSheet } from '@react-pdf/renderer';
33

44
import Svg0 from './svg';
55
import Svg1 from './Svg1';
@@ -8,9 +8,6 @@ import Svg4 from './Svg4';
88
import Star from './Star';
99
import Heart from './Heart';
1010

11-
console.log(`React version: ${React.version}`);
12-
console.log(`React-pdf version: ${ReactPDF.version}`);
13-
1411
const styles = StyleSheet.create({
1512
page: {
1613
fontSize: 20,

packages/reconciler/build/trim-reconciler.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ const KEEP_OPTIONS = {
2828
createTextInstance: true,
2929
createInstance: true,
3030
appendInitialChild: true,
31+
noTimeout: true,
32+
getCurrentUpdatePriority: true,
33+
setCurrentUpdatePriority: true,
34+
resolveUpdatePriority: true,
35+
shouldAttemptEagerTransition: true,
36+
requestPostPaintCallback: true,
37+
maySuspendCommit: true,
3138
};
3239

3340
const STATIC_OPTIONS = {
@@ -39,7 +46,9 @@ const STATIC_OPTIONS = {
3946

4047
const METHOD_KEYS = {
4148
updateContainer: true,
49+
updateContainerSync: true,
4250
createContainer: true,
51+
flushSyncWork: true,
4352
};
4453

4554
function clearReconcilerOptions(path) {
@@ -48,7 +57,7 @@ function clearReconcilerOptions(path) {
4857
const optionName = node.property?.name;
4958

5059
// If we are not visiting config object, skip.
51-
if (objectName !== '$$$hostConfig') return;
60+
if (objectName !== '$$$hostConfig' && objectName !== '$$$config') return;
5261

5362
// If it's an option we want to keep, skip.
5463
if (KEEP_OPTIONS[optionName]) return;

packages/reconciler/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
],
2525
"devDependencies": {
2626
"ast-types": "^0.14.2",
27-
"react-reconciler": "0.26.0",
27+
"react-reconciler-26": "npm:[email protected]",
28+
"react-reconciler-31": "npm:[email protected]",
2829
"recast": "^0.23.9"
2930
}
3031
}

0 commit comments

Comments
 (0)