diff options
author | 2025-01-10 10:17:46 +0800 | |
---|---|---|
committer | 2025-01-10 10:17:46 +0800 | |
commit | 51ab7b5722acecce722fb404ca6bc152a109c9e5 (patch) | |
tree | d36b73517c3437652a5e1d6e28673fdd102b3bae | |
parent | df0c5665c1c1bbbaa878d01bca28d6558762ea00 (diff) | |
download | astro-51ab7b5722acecce722fb404ca6bc152a109c9e5.tar.gz astro-51ab7b5722acecce722fb404ca6bc152a109c9e5.tar.zst astro-51ab7b5722acecce722fb404ca6bc152a109c9e5.zip |
Support checking react 19 components (#12948)
-rw-r--r-- | .changeset/sweet-turtles-flash.md | 5 | ||||
-rw-r--r-- | packages/integrations/react/server.js | 6 |
2 files changed, 10 insertions, 1 deletions
diff --git a/.changeset/sweet-turtles-flash.md b/.changeset/sweet-turtles-flash.md new file mode 100644 index 000000000..e15e055e1 --- /dev/null +++ b/.changeset/sweet-turtles-flash.md @@ -0,0 +1,5 @@ +--- +'@astrojs/react': patch +--- + +Supports checking for React 19 components diff --git a/packages/integrations/react/server.js b/packages/integrations/react/server.js index 9c3c309cc..50d6bd94b 100644 --- a/packages/integrations/react/server.js +++ b/packages/integrations/react/server.js @@ -6,6 +6,7 @@ import StaticHtml from './static-html.js'; const slotName = (str) => str.trim().replace(/[-_]([a-z])/g, (_, w) => w.toUpperCase()); const reactTypeof = Symbol.for('react.element'); +const reactTransitionalTypeof = Symbol.for('react.transitional.element'); async function check(Component, props, children) { // Note: there are packages that do some unholy things to create "components". @@ -28,7 +29,10 @@ async function check(Component, props, children) { function Tester(...args) { try { const vnode = Component(...args); - if (vnode && vnode['$$typeof'] === reactTypeof) { + if ( + vnode && + (vnode['$$typeof'] === reactTypeof || vnode['$$typeof'] === reactTransitionalTypeof) + ) { isReactComponent = true; } } catch {} |