@astrojs/react
Advanced tools
Comparing version 0.0.0-monorepos-20221010034923 to 0.0.0-schema-image-20230401003731
# @astrojs/react | ||
## 0.0.0-monorepos-20221010034923 | ||
## 0.0.0-schema-image-20230401003731 | ||
### Patch Changes | ||
- [#6698](https://github.com/withastro/astro/pull/6698) [`fc71c3f18`](https://github.com/withastro/astro/commit/fc71c3f18819ac3ad62809a7eeff5fe7840f2c4b) Thanks [@bholmesdev](https://github.com/bholmesdev)! - Update React README to reference the [new React docs](https://react.dev) | ||
- [#6696](https://github.com/withastro/astro/pull/6696) [`239b9a2fb`](https://github.com/withastro/astro/commit/239b9a2fb864fa785e4150cd8aa833de72dd3517) Thanks [@matthewp](https://github.com/matthewp)! - Add use-immer as a noExternal module | ||
## 2.1.0 | ||
### Minor Changes | ||
- [#6213](https://github.com/withastro/astro/pull/6213) [`afbbc4d5b`](https://github.com/withastro/astro/commit/afbbc4d5bfafc1779bac00b41c2a1cb1c90f2808) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Updated compilation settings to disable downlevelling for Node 14 | ||
## 2.0.2 | ||
### Patch Changes | ||
- [#5478](https://github.com/withastro/astro/pull/5478) [`1c7eef308`](https://github.com/withastro/astro/commit/1c7eef308e808aa5ed4662b53e67ec8d1b814d1f) Thanks [@nemo0](https://github.com/nemo0)! - Update READMEs for consistency | ||
## 2.0.1 | ||
### Patch Changes | ||
- [#5886](https://github.com/withastro/astro/pull/5886) [`9d4bfc76e`](https://github.com/withastro/astro/commit/9d4bfc76e8de7cf85997100145532a6fa7d2b025) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Support passing `children` as props to a React component | ||
## 2.0.0 | ||
### Major Changes | ||
- [#5782](https://github.com/withastro/astro/pull/5782) [`1f92d64ea`](https://github.com/withastro/astro/commit/1f92d64ea35c03fec43aff64eaf704dc5a9eb30a) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Remove support for Node 14. Minimum supported Node version is now >=16.12.0 | ||
## 2.0.0-beta.0 | ||
<details> | ||
<summary>See changes in 2.0.0-beta.0</summary> | ||
### Major Changes | ||
- [#5782](https://github.com/withastro/astro/pull/5782) [`1f92d64ea`](https://github.com/withastro/astro/commit/1f92d64ea35c03fec43aff64eaf704dc5a9eb30a) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Remove support for Node 14. Minimum supported Node version is now >=16.12.0 | ||
</details> | ||
## 1.2.2 | ||
### Patch Changes | ||
- [#5218](https://github.com/withastro/astro/pull/5218) [`0b1241431`](https://github.com/withastro/astro/commit/0b12414315fa81ded96587779c63c74400466078) Thanks [@MoustaphaDev](https://github.com/MoustaphaDev)! - remove unnecessary `ReactDOM.renderToString` operation | ||
## 1.2.1 | ||
### Patch Changes | ||
- [#5095](https://github.com/withastro/astro/pull/5095) [`ddfbef5ac`](https://github.com/withastro/astro/commit/ddfbef5acbd4c56d8ce1626a458b5cbb27da47fe) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Add `@types/` packages as peerDependencies | ||
## 1.2.0 | ||
### Minor Changes | ||
- [#5016](https://github.com/withastro/astro/pull/5016) [`6efeaeb39`](https://github.com/withastro/astro/commit/6efeaeb39ed7e6642b31603745750ccb9fe0ff1e) Thanks [@matthewp](https://github.com/matthewp)! - Add support for mui | ||
@@ -8,0 +63,0 @@ |
@@ -25,3 +25,3 @@ import { createElement, startTransition } from 'react'; | ||
const rootKey = isAlreadyHydrated(element); | ||
// HACK: delete internal react marker for nested components to suppress agressive warnings | ||
// HACK: delete internal react marker for nested components to suppress aggressive warnings | ||
if (rootKey) { | ||
@@ -28,0 +28,0 @@ delete element[rootKey]; |
@@ -1,2 +0,2 @@ | ||
import { AstroIntegration } from 'astro'; | ||
import type { AstroIntegration } from 'astro'; | ||
export default function (): AstroIntegration; |
@@ -18,2 +18,6 @@ import { version as ReactVersion } from "react-dom"; | ||
runtime: "automatic", | ||
// 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. | ||
importSource: ReactVersion.startsWith("18.") ? "react" : "@astrojs/react" | ||
@@ -47,5 +51,7 @@ } | ||
noExternal: [ | ||
// These are all needed to get mui to work. | ||
"@mui/material", | ||
"@mui/base", | ||
"@babel/runtime" | ||
"@babel/runtime", | ||
"use-immer" | ||
] | ||
@@ -52,0 +58,0 @@ } |
{ | ||
"name": "@astrojs/react", | ||
"description": "Use React components within Astro", | ||
"version": "0.0.0-monorepos-20221010034923", | ||
"version": "0.0.0-schema-image-20230401003731", | ||
"type": "module", | ||
@@ -38,4 +38,4 @@ "types": "./dist/index.d.ts", | ||
"@types/react-dom": "^17.0.17", | ||
"astro": "1.4.6", | ||
"astro-scripts": "0.0.8", | ||
"astro": "0.0.0-schema-image-20230401003731", | ||
"astro-scripts": "0.0.14", | ||
"react": "^18.1.0", | ||
@@ -46,6 +46,8 @@ "react-dom": "^18.1.0" | ||
"react": "^17.0.2 || ^18.0.0", | ||
"react-dom": "^17.0.2 || ^18.0.0" | ||
"react-dom": "^17.0.2 || ^18.0.0", | ||
"@types/react": "^17.0.50 || ^18.0.21", | ||
"@types/react-dom": "^17.0.17 || ^18.0.6" | ||
}, | ||
"engines": { | ||
"node": "^14.18.0 || >=16.12.0" | ||
"node": ">=16.12.0" | ||
}, | ||
@@ -52,0 +54,0 @@ "scripts": { |
# @astrojs/react ⚛️ | ||
This **[Astro integration][astro-integration]** enables server-side rendering and client-side hydration for your [React](https://reactjs.org/) components. | ||
This **[Astro integration][astro-integration]** enables server-side rendering and client-side hydration for your [React](https://react.dev/) components. | ||
@@ -46,9 +46,10 @@ ## Installation | ||
```js | ||
```js ins={2} "react()" | ||
import { defineConfig } from 'astro/config'; | ||
import react from '@astrojs/react'; | ||
export default { | ||
export default defineConfig({ | ||
// ... | ||
integrations: [react()], | ||
} | ||
}); | ||
``` | ||
@@ -55,0 +56,0 @@ |
@@ -65,4 +65,7 @@ import React from 'react'; | ||
...slots, | ||
children: children != null ? React.createElement(StaticHtml, { value: children }) : undefined, | ||
}; | ||
const newChildren = children ?? props.children; | ||
if (newChildren != null) { | ||
newProps.children = React.createElement(StaticHtml, { value: newChildren }); | ||
} | ||
const vnode = React.createElement(Component, newProps); | ||
@@ -69,0 +72,0 @@ let html; |
@@ -72,4 +72,5 @@ import React from 'react'; | ||
}; | ||
if (children != null) { | ||
newProps.children = React.createElement(StaticHtml, { value: children }); | ||
const newChildren = children ?? props.children; | ||
if (newChildren != null) { | ||
newProps.children = React.createElement(StaticHtml, { value: newChildren }); | ||
} | ||
@@ -79,3 +80,2 @@ const vnode = React.createElement(Component, newProps); | ||
if (metadata && metadata.hydrate) { | ||
html = ReactDOM.renderToString(vnode); | ||
if ('renderToReadableStream' in ReactDOM) { | ||
@@ -82,0 +82,0 @@ html = await renderToReadableStreamAsync(vnode); |
@@ -1,2 +0,2 @@ | ||
import { AstroIntegration } from 'astro'; | ||
import type { AstroIntegration } from 'astro'; | ||
import { version as ReactVersion } from 'react-dom'; | ||
@@ -69,2 +69,3 @@ | ||
'@babel/runtime', | ||
'use-immer', | ||
], | ||
@@ -71,0 +72,0 @@ }, |
@@ -6,6 +6,6 @@ { | ||
"allowJs": true, | ||
"module": "ES2020", | ||
"module": "ES2022", | ||
"outDir": "./dist", | ||
"target": "ES2020" | ||
"target": "ES2021" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33534
482
75
6