-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Add support for React 18 in @astrojs/react #2947
Conversation
This reverts commit 5279b72.
🦋 Changeset detectedLatest commit: bf8497e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
@@ -17,7 +18,7 @@ function getRenderer() { | |||
{}, | |||
{ | |||
runtime: 'automatic', | |||
importSource: '@astrojs/react', | |||
importSource: ReactVersion.startsWith('18.') ? 'react' : '@astrojs/react', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general this all LGTM, but is this line intentional? Why does this toggle between importing the integration and importing React itself here?
(The tests are passing but I don't think the first half of this ternary expression is ever hit at the moment because tests are still using React 17.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, mind explaining what this is doing @FredKSchott ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, the docs for the exist but they're in jsx-runtime.js
. This actually tripped me up, so I'll add this line of docs here:
// This option tells the JSX transform how to construct the "*/jsx-runtime" import.
// In React v17, we had to shim this due to an export map issue in React.
// In React v18, this issue was fixed and we can import "react/jsx-runtime" directly.
// See `./jsx-runtime.js` for more details.
* First pass at supporting React 18 in @astrojs/react * Try marking React 18’s `react-dom/client` as external * Try a different approach to importing different React versions * Allow resolving JSON modules * Revert "Allow resolving JSON modules" This reverts commit 5279b72. * Try the separate client entrypoint approach from withastro#2946 * Clean up diff * Trying to see something * Just keep swimming… 🐠 * update to support react 18 * add changeset * add docs Co-authored-by: delucis <[email protected]>
Changes
@astrojs/react
Testing
Docs