diff options
author | 2022-05-12 10:05:55 -0600 | |
---|---|---|
committer | 2022-05-12 10:05:55 -0600 | |
commit | 678c2b7523c7f10cfdf2eb5a73aa2bbb7e5cbc07 (patch) | |
tree | 8486dc5e86527d21a0ef686a1cc47658ec51aeb3 /packages/integrations/react/client-v17.js | |
parent | 13e697fb8042930aa76a4b81f54f014c901039db (diff) | |
download | astro-678c2b7523c7f10cfdf2eb5a73aa2bbb7e5cbc07.tar.gz astro-678c2b7523c7f10cfdf2eb5a73aa2bbb7e5cbc07.tar.zst astro-678c2b7523c7f10cfdf2eb5a73aa2bbb7e5cbc07.zip |
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
Diffstat (limited to 'packages/integrations/react/client-v17.js')
-rw-r--r-- | packages/integrations/react/client-v17.js | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/packages/integrations/react/client-v17.js b/packages/integrations/react/client-v17.js index 64284a0b0..32ba87558 100644 --- a/packages/integrations/react/client-v17.js +++ b/packages/integrations/react/client-v17.js @@ -1,15 +1,18 @@ import { createElement } from 'react'; -import { hydrate } from 'react-dom'; +import { render, hydrate } from 'react-dom'; import StaticHtml from './static-html.js'; -export default (element) => (Component, props, children) => - hydrate( - createElement( +export default (element) => (Component, props, children, { client }) => + { + const componentEl = createElement( Component, - { ...props, suppressHydrationWarning: true }, + props, children != null - ? createElement(StaticHtml, { value: children, suppressHydrationWarning: true }) + ? createElement(StaticHtml, { value: children }) : children - ), - element - ); + ); + if (client === 'only') { + return render(componentEl, element); + } + return hydrate(componentEl, element); + }; |