mirror of
https://github.com/withastro/astro.git
synced 2025-02-03 22:29:08 -05:00
Support checking react 19 components (#12948)
This commit is contained in:
parent
df0c5665c1
commit
51ab7b5722
2 changed files with 10 additions and 1 deletions
5
.changeset/sweet-turtles-flash.md
Normal file
5
.changeset/sweet-turtles-flash.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@astrojs/react': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Supports checking for React 19 components
|
|
@ -6,6 +6,7 @@ import StaticHtml from './static-html.js';
|
||||||
|
|
||||||
const slotName = (str) => str.trim().replace(/[-_]([a-z])/g, (_, w) => w.toUpperCase());
|
const slotName = (str) => str.trim().replace(/[-_]([a-z])/g, (_, w) => w.toUpperCase());
|
||||||
const reactTypeof = Symbol.for('react.element');
|
const reactTypeof = Symbol.for('react.element');
|
||||||
|
const reactTransitionalTypeof = Symbol.for('react.transitional.element');
|
||||||
|
|
||||||
async function check(Component, props, children) {
|
async function check(Component, props, children) {
|
||||||
// Note: there are packages that do some unholy things to create "components".
|
// 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) {
|
function Tester(...args) {
|
||||||
try {
|
try {
|
||||||
const vnode = Component(...args);
|
const vnode = Component(...args);
|
||||||
if (vnode && vnode['$$typeof'] === reactTypeof) {
|
if (
|
||||||
|
vnode &&
|
||||||
|
(vnode['$$typeof'] === reactTypeof || vnode['$$typeof'] === reactTransitionalTypeof)
|
||||||
|
) {
|
||||||
isReactComponent = true;
|
isReactComponent = true;
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
|
|
Loading…
Add table
Reference in a new issue