UNPKG

1.62 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var tslib_1 = require("tslib");
4var React = tslib_1.__importStar(require("react"));
5var detectBackend_1 = require("../utils/detectBackend");
6var useClientPhase_1 = require("../utils/useClientPhase");
7var LazyServerBoundary = function (_a) {
8 var children = _a.children;
9 return React.createElement(React.Fragment, null, children);
10};
11var LazyClientBoundary = function (_a) {
12 var children = _a.children, fallback = _a.fallback;
13 return (React.createElement(React.Suspense
14 // we keep fallback null during hydration as it is expected behavior for "ssr-ed" Suspense blocks - they should not "fallback"
15 // see https://github.com/sebmarkbage/react/blob/185700696ebbe737c99bd6c4b678d5f2a923bd29/packages/react-dom/src/__tests__/ReactServerRenderingHydration-test.js#L668-L682
16 , {
17 // we keep fallback null during hydration as it is expected behavior for "ssr-ed" Suspense blocks - they should not "fallback"
18 // see https://github.com/sebmarkbage/react/blob/185700696ebbe737c99bd6c4b678d5f2a923bd29/packages/react-dom/src/__tests__/ReactServerRenderingHydration-test.js#L668-L682
19 fallback: useClientPhase_1.useIsClientPhase() ? fallback : undefined }, children));
20};
21/**
22 * React.Suspense "as-is" replacement. Automatically "removed" during SSR and "patched" to work accordingly on the clientside
23 *
24 * @see {@link HydrationController} has to wrap entire application in order to provide required information
25 */
26exports.LazyBoundary = detectBackend_1.isBackend ? LazyServerBoundary : LazyClientBoundary;