Skip to content

fix(preact): avoid triggering React 19 hook error logs#15619

Merged
ematipico merged 3 commits into
withastro:mainfrom
rururux:fix-react-invalid-hook-call
Feb 23, 2026
Merged

fix(preact): avoid triggering React 19 hook error logs#15619
ematipico merged 3 commits into
withastro:mainfrom
rururux:fix-react-invalid-hook-call

Conversation

@rururux
Copy link
Copy Markdown
Member

@rururux rururux commented Feb 23, 2026

fixes: #15341

Changes

Updated the error filtering logic to support React 19.
Previously, the "Invalid hook call" error (which occurs when using React and Preact integrations together) was filtered out to prevent noise. However, the filtering failed for React 19 because its error message format had changed.
This PR ensures that the new React 19 error messages are correctly identified and filtered, maintaining a clean console output for users.

Testing

Added a regression test to verify that the "Invalid hook call" error is no longer logged when React 19 and Preact are used together.
The hookError utility in the test was adapted from the following implementation:

function hookError() {
const error = console.error;
const errors = [];
console.error = function (...args) {
errors.push(args);
};
return () => {
console.error = error;
return errors;
};
}

Docs

N/A, bug fix

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 23, 2026

🦋 Changeset detected

Latest commit: 71ecd40

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) pkg: astro Related to the core `astro` package (scope) labels Feb 23, 2026
@ematipico ematipico merged commit bbfa7c8 into withastro:main Feb 23, 2026
22 checks passed
@rururux
Copy link
Copy Markdown
Member Author

rururux commented Feb 23, 2026

Thank you so much! ☺️

@rururux rururux deleted the fix-react-invalid-hook-call branch February 23, 2026 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope) 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.

React: Invalid hook call

2 participants