From 5f47408c978410c7f86f5fc314aa5503b3702c95 Mon Sep 17 00:00:00 2001 From: Ben Holmes Date: Thu, 12 May 2022 10:05:55 -0600 Subject: [PATCH] Fix: React - Use "createRoot" instead of "hydrateRoot" for `client:only` (#3337) * feat: pass "client" directive to clientEntrypoints * refactor: remove hydration warning suppression react 17 * feat: remove hydration warning suppression react 18 * chore: changeset * fix: change metadata to options bag --- src/runtime/server/hydration.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/runtime/server/hydration.ts b/src/runtime/server/hydration.ts index e7267fe16e3c..4d8ab48f0b68 100644 --- a/src/runtime/server/hydration.ts +++ b/src/runtime/server/hydration.ts @@ -110,15 +110,15 @@ export async function generateHydrateScript( ); } - let hydrationSource = ``; - - hydrationSource += renderer.clientEntrypoint + const hydrationSource = renderer.clientEntrypoint ? `const [{ ${ componentExport.value }: Component }, { default: hydrate }] = await Promise.all([import("${await result.resolve( componentUrl )}"), import("${await result.resolve(renderer.clientEntrypoint)}")]); - return (el, children) => hydrate(el)(Component, ${serializeProps(props)}, children); + return (el, children) => hydrate(el)(Component, ${serializeProps( + props + )}, children, ${JSON.stringify({ client: hydrate })}); ` : `await import("${await result.resolve(componentUrl)}"); return () => {};