@taujs/react 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +7 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -157,10 +157,13 @@ function hydrateApp({
|
|
|
157
157
|
onSuccess
|
|
158
158
|
}) {
|
|
159
159
|
const { log, warn, error } = createUILogger(logger, { debugCategory: "ssr", context: { scope: "react-hydration" }, enableDebug });
|
|
160
|
-
const mountCSR = (rootEl) => {
|
|
160
|
+
const mountCSR = (rootEl, initialData) => {
|
|
161
161
|
rootEl.innerHTML = "";
|
|
162
|
+
const store = createSSRStore(initialData);
|
|
162
163
|
const root = createRoot(rootEl);
|
|
163
|
-
root.render(
|
|
164
|
+
root.render(
|
|
165
|
+
/* @__PURE__ */ jsx2(React2.StrictMode, { children: /* @__PURE__ */ jsx2(SSRStoreProvider, { store, children: appComponent }) })
|
|
166
|
+
);
|
|
164
167
|
};
|
|
165
168
|
const startHydration = (rootEl, initialData) => {
|
|
166
169
|
if (enableDebug) log("Hydration started");
|
|
@@ -193,8 +196,9 @@ function hydrateApp({
|
|
|
193
196
|
}
|
|
194
197
|
const data = window[dataKey];
|
|
195
198
|
if (data === void 0) {
|
|
199
|
+
const data2 = {};
|
|
196
200
|
if (enableDebug) warn(`No initial SSR data at window["${dataKey}"]. Mounting CSR.`);
|
|
197
|
-
mountCSR(rootEl);
|
|
201
|
+
mountCSR(rootEl, data2);
|
|
198
202
|
return;
|
|
199
203
|
}
|
|
200
204
|
startHydration(rootEl, data);
|