lambda-packages
lambda-packages copied to clipboard
Fix: Invalid hook call when user use export jsx function
Changes
- Update
vite-plugin-jsx/tag.tsfor understanding ofexport {X},export const X,export default const Xand so on. You can see the full list fromastro/test/react-jsx-export.test.jsandastro/test/fixtures/react-jsx-export - The full export examples are reference MDN#export.syntax
- You can see more details from issue#4220. Close #4220
- This cr is refers to pull#4385, but add tests and support for
Anonymous Function Default ExportandAnonymous Arrow Function Default Export.
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.