Skip to content

Commit 42cbca0

Browse files
committed
fix(react): guard against undefined 48357typeof in check()
The check() function assumes Component['48357typeof'] is always defined when typeof Component === 'object', but non-React component objects (e.g. Svelte components imported via barrel) may not have 48357typeof. Calling .toString() on undefined throws TypeError. Add a null guard so the check returns false for non-React components instead of crashing.
1 parent 4806275 commit 42cbca0

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

packages/integrations/react/src/server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ async function check(
2323
// Note: there are packages that do some unholy things to create "components".
2424
// Checking the $$typeof property catches most of these patterns.
2525
if (typeof Component === 'object') {
26-
return Component['$$typeof'].toString().slice('Symbol('.length).startsWith('react');
26+
const $$typeof = Component['$$typeof'];
27+
return $$typeof != null && $$typeof.toString().slice('Symbol('.length).startsWith('react');
2728
}
2829
if (typeof Component !== 'function') return false;
2930
if (Component.name === 'QwikComponent') return false;

0 commit comments

Comments
 (0)