summaryrefslogtreecommitdiff
path: root/packages/integrations/react
diff options
context:
space:
mode:
authorGravatar HiDeoo <494699+HiDeoo@users.noreply.github.com> 2023-01-25 23:31:57 +0100
committerGravatar GitHub <noreply@github.com> 2023-01-25 16:31:57 -0600
commit9d4bfc76e8de7cf85997100145532a6fa7d2b025 (patch)
tree03cf2a6a99106987f395b2517cf431c1d0eefc1e /packages/integrations/react
parentdabce6b8c684f851c3535f8acead06cbef6dce2a (diff)
downloadastro-9d4bfc76e8de7cf85997100145532a6fa7d2b025.tar.gz
astro-9d4bfc76e8de7cf85997100145532a6fa7d2b025.tar.zst
astro-9d4bfc76e8de7cf85997100145532a6fa7d2b025.zip
Support passing `children` as props to a React component (#5886)
Diffstat (limited to 'packages/integrations/react')
-rw-r--r--packages/integrations/react/server-v17.js5
-rw-r--r--packages/integrations/react/server.js5
2 files changed, 7 insertions, 3 deletions
diff --git a/packages/integrations/react/server-v17.js b/packages/integrations/react/server-v17.js
index 8613ef01a..ab5b06350 100644
--- a/packages/integrations/react/server-v17.js
+++ b/packages/integrations/react/server-v17.js
@@ -62,8 +62,11 @@ function renderToStaticMarkup(Component, props, { default: children, ...slotted
const newProps = {
...props,
...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);
let html;
if (metadata && metadata.hydrate) {
diff --git a/packages/integrations/react/server.js b/packages/integrations/react/server.js
index 1ebd044cf..01a135a9b 100644
--- a/packages/integrations/react/server.js
+++ b/packages/integrations/react/server.js
@@ -69,8 +69,9 @@ async function renderToStaticMarkup(Component, props, { default: children, ...sl
...props,
...slots,
};
- 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 });
}
const vnode = React.createElement(Component, newProps);
let html;
td>Gravatar Ashcon Partovi 1-0/+32 2023-08-31fix(runtime): `fs.cp` edge cases (#4439)Gravatar dave caruso 2-8/+44 * yippee * enable cpSync tests * much better * that doesnt actually do anything * lose 2023-08-31only set initial debugger breakpoint once (#4441)Gravatar Dylan Conway 1-2/+11 * unset `set_breakpoint_on_first_line` on reload * move to `module_loader.zig` 2023-08-31Make breakpoints faster in VSCode extensionGravatar Ashcon Partovi 1-241/+327 2023-08-31`bun install` correctly join dependency URLs (#4421)Gravatar Julian 6-64/+243 * use WTF to join registry strings * show dependency error messages, better join error We actually report errors when enqueuing dependencies now. I also made the join URLs error message read better. It'd be cleaner to handle it all in one place, but there's currently no way to propagate the data up. * starting on registry URL tests * added more registry URL tests * [install] prevent optional/peer deps from failing builds Couldn't get the peer dependency test to work, but the code is there. * ran prettier * changed error note to use realname, updated tests * ran prettier again... 2023-08-31get name if not provided in `FormData.append` (#4434)Gravatar Dylan Conway 4-5/+45 * get file name from blob if not provided * add test * another test * format 2023-08-31Fix vscode debug terminalGravatar Ashcon Partovi 1-21/+0