Skip to content

fix: prevent to render react components on preact#15504

Open
fkatsuhiro wants to merge 2 commits intowithastro:mainfrom
fkatsuhiro:fix/prevent-react-render-on-preact
Open

fix: prevent to render react components on preact#15504
fkatsuhiro wants to merge 2 commits intowithastro:mainfrom
fkatsuhiro:fix/prevent-react-render-on-preact

Conversation

@fkatsuhiro
Copy link
Contributor

Changes

issue : #15341

Neither React nor Preact components were clearly identified during the check phase. As a result, both were allowed to proceed to the rendering stage, and framework identification only occurred after an error was triggered.

components name: Counter
Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.
components name: PreactCounter

I discovered a definitive structural difference in the transpiled output (via Component.toString()):
Preact: Uses a variable named _jsxFileName for source mapping.
React: Uses a raw string literal containing the absolute/relative file path.

ex)
Preact : fileName: _jsxFileName,
React : fileName: "/Users/katsu/personel_dev/astro-v6-react-19-hook-issue/src/components/react/ReactCounter.tsx",

Testing

2026-02-14.3.19.59.mov

Docs

@changeset-bot
Copy link

changeset-bot bot commented Feb 13, 2026

🦋 Changeset detected

Latest commit: e52453d

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added pkg: preact Related to Preact (scope) pkg: integration Related to any renderer integration (scope) labels Feb 13, 2026
@fkatsuhiro fkatsuhiro mentioned this pull request Feb 13, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: integration Related to any renderer integration (scope) pkg: preact Related to Preact (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant