diff options
author | Vitaly Takmazov | 2022-11-08 00:51:25 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-01-13 10:37:58 +0300 |
commit | fcc333d0cc14a03da5ccbe6f38e1359f14bc4e98 (patch) | |
tree | c00beffba276991ab2e895feeace1a1f027d8d07 | |
parent | 431bd603c143b93cfbfcc7beb81408755dbed0ce (diff) |
react-dom: conditional create/hydrate root based on the initial props
-rw-r--r-- | vnext/src/index.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/vnext/src/index.js b/vnext/src/index.js index fd5024c9..11a78a48 100644 --- a/vnext/src/index.js +++ b/vnext/src/index.js @@ -9,7 +9,7 @@ import 'core-js/modules/es.symbol'; import 'core-js/modules/web.dom-collections.iterator'; import 'url-polyfill'; import { StrictMode, lazy } from 'react'; -import { hydrateRoot } from 'react-dom/client'; +import { createRoot, hydrateRoot } from 'react-dom/client'; import { BrowserRouter } from 'react-router-dom'; import { CookiesProvider } from 'react-cookie'; @@ -40,4 +40,9 @@ const JuickApp = () => ( </StrictMode> ); -hydrateRoot(document.getElementById('app'), <JuickApp />); +let root = document.getElementById('app'); +if (window.__PROPS__) { + hydrateRoot(root, <JuickApp />); +} else { + createRoot(root).render(<JuickApp />); +} |