Skip to content

Commit

Permalink
Support checking react 19 components (#12948)
Browse files Browse the repository at this point in the history
  • Loading branch information
bluwy authored Jan 10, 2025
1 parent df0c566 commit 51ab7b5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/sweet-turtles-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/react': patch
---

Supports checking for React 19 components
6 changes: 5 additions & 1 deletion packages/integrations/react/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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".
Expand All @@ -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 {}
Expand Down

0 comments on commit 51ab7b5

Please sign in to comment.