0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-01-27 22:19:04 -05:00

Support checking react 19 components (#12948)

This commit is contained in:
Bjorn Lu 2025-01-10 10:17:46 +08:00 committed by GitHub
parent df0c5665c1
commit 51ab7b5722
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'@astrojs/react': patch
---
Supports checking for React 19 components

View file

@ -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 {}