summaryrefslogtreecommitdiff
path: root/packages/integrations/react/client.js
diff options
context:
space:
mode:
authorGravatar Robin Neal <robinneal429@gmail.com> 2023-05-04 15:23:00 +0100
committerGravatar GitHub <noreply@github.com> 2023-05-04 15:23:00 +0100
commitca329bbcae7a6075af4f428f6f64466e9d152c8f (patch)
tree0139a99c0cc60b22758e75ebb519893a5447ebb2 /packages/integrations/react/client.js
parentdfb9e4270a7c05c292a549777408278fcbe162ab (diff)
downloadastro-ca329bbcae7a6075af4f428f6f64466e9d152c8f.tar.gz
astro-ca329bbcae7a6075af4f428f6f64466e9d152c8f.tar.zst
astro-ca329bbcae7a6075af4f428f6f64466e9d152c8f.zip
Generate unique ids within each React island (#6976)
Diffstat (limited to 'packages/integrations/react/client.js')
-rw-r--r--packages/integrations/react/client.js7
1 files changed, 5 insertions, 2 deletions
diff --git a/packages/integrations/react/client.js b/packages/integrations/react/client.js
index 3807ab410..366d499e3 100644
--- a/packages/integrations/react/client.js
+++ b/packages/integrations/react/client.js
@@ -13,6 +13,9 @@ function isAlreadyHydrated(element) {
export default (element) =>
(Component, props, { default: children, ...slotted }, { client }) => {
if (!element.hasAttribute('ssr')) return;
+ const renderOptions = {
+ identifierPrefix: element.getAttribute('prefix')
+ }
for (const [key, value] of Object.entries(slotted)) {
props[key] = createElement(StaticHtml, { value, name: key });
}
@@ -28,10 +31,10 @@ export default (element) =>
}
if (client === 'only') {
return startTransition(() => {
- createRoot(element).render(componentEl);
+ createRoot(element, renderOptions).render(componentEl);
});
}
return startTransition(() => {
- hydrateRoot(element, componentEl);
+ hydrateRoot(element, componentEl, renderOptions);
});
};