summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Bjorn Lu <bjornlu.dev@gmail.com> 2025-01-10 10:17:46 +0800
committerGravatar GitHub <noreply@github.com> 2025-01-10 10:17:46 +0800
commit51ab7b5722acecce722fb404ca6bc152a109c9e5 (patch)
treed36b73517c3437652a5e1d6e28673fdd102b3bae
parentdf0c5665c1c1bbbaa878d01bca28d6558762ea00 (diff)
downloadastro-51ab7b5722acecce722fb404ca6bc152a109c9e5.tar.gz
astro-51ab7b5722acecce722fb404ca6bc152a109c9e5.tar.zst
astro-51ab7b5722acecce722fb404ca6bc152a109c9e5.zip
Support checking react 19 components (#12948)
-rw-r--r--.changeset/sweet-turtles-flash.md5
-rw-r--r--packages/integrations/react/server.js6
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 {}