fix(react): guard against undefined $$typeof in check() - #17553
Open
Clickin wants to merge 1 commit into
Open
Conversation
|
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.
Clickin
force-pushed
the
fix/react-check-undefined-typeof
branch
from
July 30, 2026 03:22
1e7a9e2 to
42cbca0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Adds a null guard in the
check()function in@astrojs/react's server renderer to preventTypeErrorwhenComponent["$$typeof"]is undefined on non-React component objects.Background
When
@astrojs/reactis used alongside other framework integrations (e.g.@astrojs/svelte), thecheck()function may receive non-React component objects. The current code calls.toString()onComponent["$$typeof"]without checking if it exists:Fix
Extract
$$typeofinto a local variable and use!= nullshort-circuit, returningfalsefor components that lack the property:Related issue
Closes #17552