Skip to content

Commit

Permalink
Adds support for react 19 (#4623)
Browse files Browse the repository at this point in the history
* Adds support for react 19

* Add to fgiles
  • Loading branch information
JoviDeCroock authored Jan 7, 2025
1 parent df1f20d commit a1ff5f3
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
4 changes: 4 additions & 0 deletions compat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
"import": "./server.mjs",
"require": "./server.js"
},
"./react-19": {
"import": "./react-19.mjs",
"require": "./react-19.js"
},
"./jsx-runtime": {
"import": "./jsx-runtime.mjs",
"require": "./jsx-runtime.js"
Expand Down
12 changes: 12 additions & 0 deletions compat/react-19.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require('preact/compat');

const { options } = require('preact');

const oldVNode = options.vnode;
options.vnode = vnode => {
if (typeof vnode.type === 'function') {
vnode.type._forwarded = true;
}

if (oldVNode) oldVNode(vnode);
};
12 changes: 12 additions & 0 deletions compat/react-19.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'preact/compat';

import { options } from 'preact';

const oldVNode = options.vnode;
options.vnode = vnode => {
if (typeof vnode.type === 'function') {
vnode.type._forwarded = true;
}

if (oldVNode) oldVNode(vnode);
};
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@
"import": "./compat/jsx-runtime.mjs",
"require": "./compat/jsx-runtime.js"
},
"./compat/react-19": {
"types": "./compat/src/index.d.ts",
"import": "./compat/react-19.mjs",
"require": "./compat/react-19.js"
},
"./compat/jsx-dev-runtime": {
"types": "./jsx-runtime/src/index.d.ts",
"import": "./compat/jsx-dev-runtime.mjs",
Expand Down Expand Up @@ -166,6 +171,8 @@
"compat/test-utils.js",
"compat/jsx-runtime.js",
"compat/jsx-runtime.mjs",
"compat/react-19.js",
"compat/react-19.mjs",
"compat/jsx-dev-runtime.js",
"compat/jsx-dev-runtime.mjs",
"compat/package.json",
Expand Down

0 comments on commit a1ff5f3

Please sign in to comment.