@sitecore-jss/sitecore-jss-react 22.12.0-canary.2 → 22.12.0-canary.4
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.
|
@@ -53,7 +53,7 @@ class ErrorBoundary extends react_1.default.Component {
|
|
|
53
53
|
((_b = this.props.sitecoreContext) === null || _b === void 0 ? void 0 : _b.pageState) === layout_1.LayoutServicePageState.Preview);
|
|
54
54
|
}
|
|
55
55
|
render() {
|
|
56
|
-
var _a;
|
|
56
|
+
var _a, _b;
|
|
57
57
|
if (this.state.error) {
|
|
58
58
|
if (this.props.errorComponent) {
|
|
59
59
|
return react_1.default.createElement(this.props.errorComponent, { error: this.state.error });
|
|
@@ -76,7 +76,7 @@ class ErrorBoundary extends react_1.default.Component {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
// do not apply suspense when suspense is disabled or when on already dynamic components
|
|
79
|
-
if (this.props.disableSuspense || this.props.isDynamic) {
|
|
79
|
+
if (((_b = this.props.disableSuspense) !== null && _b !== void 0 ? _b : true) || this.props.isDynamic) {
|
|
80
80
|
return this.props.children;
|
|
81
81
|
}
|
|
82
82
|
return (react_1.default.createElement(react_1.Suspense, { fallback: react_1.default.createElement("h4", null, this.props.componentLoadingMessage || this.defaultLoadingMessage) }, this.props.children));
|
|
@@ -93,7 +93,7 @@ class PlaceholderCommon extends react_1.default.Component {
|
|
|
93
93
|
const _b = this.props, { name, fields: placeholderFields, params: placeholderParams, missingComponentComponent, hiddenRenderingComponent } = _b, placeholderProps = __rest(_b, ["name", "fields", "params", "missingComponentComponent", "hiddenRenderingComponent"]);
|
|
94
94
|
const transformedComponents = placeholderData
|
|
95
95
|
.map((rendering, index) => {
|
|
96
|
-
var _a, _b
|
|
96
|
+
var _a, _b;
|
|
97
97
|
const key = rendering.uid
|
|
98
98
|
? rendering.uid
|
|
99
99
|
: `component-${index}`;
|
|
@@ -150,14 +150,12 @@ class PlaceholderCommon extends react_1.default.Component {
|
|
|
150
150
|
const isByocWrapper = componentRendering.componentName === BYOCWrapper_1.BYOC_WRAPPER_RENDERING_NAME;
|
|
151
151
|
// all dynamic elements will have a separate render prop
|
|
152
152
|
const isDynamicComponent = !!((_a = component.render) === null || _a === void 0 ? void 0 : _a.preload);
|
|
153
|
-
const disableSuspense = this.props.disableSuspense ||
|
|
154
|
-
((_b = this.props.sitecoreContext) === null || _b === void 0 ? void 0 : _b.pageState) === layout_1.LayoutServicePageState.Edit;
|
|
155
153
|
// wrapping with error boundary could cause problems in case where parent component uses withPlaceholder HOC and tries to access its children props
|
|
156
154
|
// that's why we need to expose element's props here
|
|
157
|
-
rendered = (react_1.default.createElement(ErrorBoundary_1.default, Object.assign({ key: rendered.type + '-' + index, errorComponent: this.props.errorComponent, componentLoadingMessage: this.props.componentLoadingMessage, type: type, isDynamic: isDynamicComponent || isByocWrapper, disableSuspense: disableSuspense }, rendered.props), rendered));
|
|
155
|
+
rendered = (react_1.default.createElement(ErrorBoundary_1.default, Object.assign({ key: rendered.type + '-' + index, errorComponent: this.props.errorComponent, componentLoadingMessage: this.props.componentLoadingMessage, type: type, isDynamic: isDynamicComponent || isByocWrapper, disableSuspense: this.props.disableSuspense }, rendered.props), rendered));
|
|
158
156
|
}
|
|
159
157
|
// if editMode is equal to 'metadata' then emit shallow chromes for hydration in Pages
|
|
160
|
-
if (((
|
|
158
|
+
if (((_b = this.props.sitecoreContext) === null || _b === void 0 ? void 0 : _b.editMode) === layout_1.EditMode.Metadata) {
|
|
161
159
|
return (react_1.default.createElement(PlaceholderMetadata_1.PlaceholderMetadata, { key: key, rendering: rendering }, rendered));
|
|
162
160
|
}
|
|
163
161
|
return rendered;
|
|
@@ -28,7 +28,7 @@ class ErrorBoundary extends React.Component {
|
|
|
28
28
|
((_b = this.props.sitecoreContext) === null || _b === void 0 ? void 0 : _b.pageState) === LayoutServicePageState.Preview);
|
|
29
29
|
}
|
|
30
30
|
render() {
|
|
31
|
-
var _a;
|
|
31
|
+
var _a, _b;
|
|
32
32
|
if (this.state.error) {
|
|
33
33
|
if (this.props.errorComponent) {
|
|
34
34
|
return React.createElement(this.props.errorComponent, { error: this.state.error });
|
|
@@ -51,7 +51,7 @@ class ErrorBoundary extends React.Component {
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
// do not apply suspense when suspense is disabled or when on already dynamic components
|
|
54
|
-
if (this.props.disableSuspense || this.props.isDynamic) {
|
|
54
|
+
if (((_b = this.props.disableSuspense) !== null && _b !== void 0 ? _b : true) || this.props.isDynamic) {
|
|
55
55
|
return this.props.children;
|
|
56
56
|
}
|
|
57
57
|
return (React.createElement(Suspense, { fallback: React.createElement("h4", null, this.props.componentLoadingMessage || this.defaultLoadingMessage) }, this.props.children));
|
|
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import React from 'react';
|
|
13
13
|
import { MissingComponent } from './MissingComponent';
|
|
14
|
-
import { EditMode, isDynamicPlaceholder, getDynamicPlaceholderPattern,
|
|
14
|
+
import { EditMode, isDynamicPlaceholder, getDynamicPlaceholderPattern, } from '@sitecore-jss/sitecore-jss/layout';
|
|
15
15
|
import { constants } from '@sitecore-jss/sitecore-jss';
|
|
16
16
|
import { convertAttributesToReactProps } from '../utils';
|
|
17
17
|
import { HiddenRendering } from './HiddenRendering';
|
|
@@ -87,7 +87,7 @@ export class PlaceholderCommon extends React.Component {
|
|
|
87
87
|
const _b = this.props, { name, fields: placeholderFields, params: placeholderParams, missingComponentComponent, hiddenRenderingComponent } = _b, placeholderProps = __rest(_b, ["name", "fields", "params", "missingComponentComponent", "hiddenRenderingComponent"]);
|
|
88
88
|
const transformedComponents = placeholderData
|
|
89
89
|
.map((rendering, index) => {
|
|
90
|
-
var _a, _b
|
|
90
|
+
var _a, _b;
|
|
91
91
|
const key = rendering.uid
|
|
92
92
|
? rendering.uid
|
|
93
93
|
: `component-${index}`;
|
|
@@ -144,14 +144,12 @@ export class PlaceholderCommon extends React.Component {
|
|
|
144
144
|
const isByocWrapper = componentRendering.componentName === BYOC_WRAPPER_RENDERING_NAME;
|
|
145
145
|
// all dynamic elements will have a separate render prop
|
|
146
146
|
const isDynamicComponent = !!((_a = component.render) === null || _a === void 0 ? void 0 : _a.preload);
|
|
147
|
-
const disableSuspense = this.props.disableSuspense ||
|
|
148
|
-
((_b = this.props.sitecoreContext) === null || _b === void 0 ? void 0 : _b.pageState) === LayoutServicePageState.Edit;
|
|
149
147
|
// wrapping with error boundary could cause problems in case where parent component uses withPlaceholder HOC and tries to access its children props
|
|
150
148
|
// that's why we need to expose element's props here
|
|
151
|
-
rendered = (React.createElement(ErrorBoundary, Object.assign({ key: rendered.type + '-' + index, errorComponent: this.props.errorComponent, componentLoadingMessage: this.props.componentLoadingMessage, type: type, isDynamic: isDynamicComponent || isByocWrapper, disableSuspense: disableSuspense }, rendered.props), rendered));
|
|
149
|
+
rendered = (React.createElement(ErrorBoundary, Object.assign({ key: rendered.type + '-' + index, errorComponent: this.props.errorComponent, componentLoadingMessage: this.props.componentLoadingMessage, type: type, isDynamic: isDynamicComponent || isByocWrapper, disableSuspense: this.props.disableSuspense }, rendered.props), rendered));
|
|
152
150
|
}
|
|
153
151
|
// if editMode is equal to 'metadata' then emit shallow chromes for hydration in Pages
|
|
154
|
-
if (((
|
|
152
|
+
if (((_b = this.props.sitecoreContext) === null || _b === void 0 ? void 0 : _b.editMode) === EditMode.Metadata) {
|
|
155
153
|
return (React.createElement(PlaceholderMetadata, { key: key, rendering: rendering }, rendered));
|
|
156
154
|
}
|
|
157
155
|
return rendered;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-jss/sitecore-jss-react",
|
|
3
|
-
"version": "22.12.0-canary.
|
|
3
|
+
"version": "22.12.0-canary.4",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -61,13 +61,13 @@
|
|
|
61
61
|
"react-dom": "^19.1.0"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@sitecore-jss/sitecore-jss": "22.12.0-canary.
|
|
64
|
+
"@sitecore-jss/sitecore-jss": "22.12.0-canary.4",
|
|
65
65
|
"fast-deep-equal": "^3.1.3",
|
|
66
66
|
"style-attr": "^1.3.0"
|
|
67
67
|
},
|
|
68
68
|
"description": "",
|
|
69
69
|
"types": "types/index.d.ts",
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "2ff774cfd709c31691021da6ef5c49689a1a02a8",
|
|
71
71
|
"files": [
|
|
72
72
|
"dist",
|
|
73
73
|
"types"
|
|
@@ -66,8 +66,11 @@ export interface PlaceholderProps {
|
|
|
66
66
|
*/
|
|
67
67
|
componentLoadingMessage?: string;
|
|
68
68
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
69
|
+
* @deprecated The `disableSuspense` prop is deprecated and will be removed in version 23.0.0.
|
|
70
|
+
* The default value is set to `true` to avoid forcing Suspense usage across all components which could negatively impact performance metrics. Suspense can now be enabled explicitly when needed.
|
|
71
|
+
*
|
|
72
|
+
* If `false`, enables Suspense in ErrorBoundary for the components rendered by placeholder.
|
|
73
|
+
* @default true
|
|
71
74
|
*/
|
|
72
75
|
disableSuspense?: boolean;
|
|
73
76
|
}
|