Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Invalid hook call when user use export jsx function #4831

Merged
merged 3 commits into from
Sep 21, 2022

Conversation

yuhang-dong
Copy link
Contributor

@yuhang-dong yuhang-dong commented Sep 21, 2022

Changes

Testing

You can see the full tests from astro/test//react-jsx-export.test.js and astro/test/fixtures/react-jsx-export.

The test will prevent react warning like below:

Warning: 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://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.`

Docs

This is not affect a user's behavior, so we don't need to update docs.

@changeset-bot
Copy link

changeset-bot bot commented Sep 21, 2022

🦋 Changeset detected

Latest commit: b1c1b55

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

This PR includes changesets to release 16 packages
Name Type
astro Patch
@e2e/astro-component Patch
@e2e/error-cyclic Patch
@e2e/error-react-spectrum Patch
@e2e/error-sass Patch
@e2e/errors Patch
@e2e/hydration-race Patch
@e2e/lit-component Patch
@e2e/preact-component Patch
@e2e/react-component Patch
@e2e/solid-component Patch
@e2e/solid-recurse Patch
@e2e/svelte-component Patch
@e2e/e2e-tailwindcss Patch
@e2e/ts-resolution Patch
@e2e/third-party-astro Patch

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 the pkg: astro Related to the core `astro` package (scope) label Sep 21, 2022
Copy link
Contributor

@matthewp matthewp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking because this is marked as major.

@@ -0,0 +1,5 @@
---
'astro': major
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this marked as major? Was that a mistake? I think this can be a patch because it fixes a bug, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right! Accepted

@matthewp
Copy link
Contributor

Thanks so much, this looks great! Love all the tests.

Copy link
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is amazing, thank you for the fix! If you can mark this as patch we'll get this released ASAP.

@yuhang-dong
Copy link
Contributor Author

CI / Test: macos-latest (node@14) Failed for Error: Timeout of 20000ms exceeded.
And CI / Test: windows-latest (node@14) kept hanging up.
Could you give me some suggestions to solve these problems? @matthewp @natemoo-re
Thanks!

@matthewp
Copy link
Contributor

@yuhang-dong these tests can be flakey, I think I just need to rerun it.

@matthewp matthewp merged commit 29b29e6 into withastro:main Sep 21, 2022
@astrobot-houston astrobot-houston mentioned this pull request Sep 21, 2022
@whs whs mentioned this pull request Nov 5, 2022
1 task
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)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid Hook Call in React
3 participants