Fix: React hydration failure (#3094)

* fix: react hydration failure

* chore: changeset
This commit is contained in:
Ben Holmes 2022-04-12 17:00:52 -04:00 committed by GitHub
parent 6d0b0597bd
commit 564caf24c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Expose "metadata" to component integrations renderToStaticMarkup function

View file

@ -260,7 +260,7 @@ Did you mean to enable ${formatList(probableRendererNames.map((r) => '`' + r + '
// We already know that renderer.ssr.check() has failed // We already know that renderer.ssr.check() has failed
// but this will throw a much more descriptive error! // but this will throw a much more descriptive error!
renderer = matchingRenderers[0]; renderer = matchingRenderers[0];
({ html } = await renderer.ssr.renderToStaticMarkup(Component, props, children)); ({ html } = await renderer.ssr.renderToStaticMarkup(Component, props, children, metadata));
} else { } else {
throw new Error(`Unable to render ${metadata.displayName}! throw new Error(`Unable to render ${metadata.displayName}!
@ -279,7 +279,7 @@ If you're still stuck, please open an issue on GitHub or join us at https://astr
if (metadata.hydrate === 'only') { if (metadata.hydrate === 'only') {
html = await renderSlot(result, slots?.fallback); html = await renderSlot(result, slots?.fallback);
} else { } else {
({ html } = await renderer.ssr.renderToStaticMarkup(Component, props, children)); ({ html } = await renderer.ssr.renderToStaticMarkup(Component, props, children, metadata));
} }
} }