@sitecore-jss/sitecore-jss-react 22.7.0-canary.1 → 22.7.0-canary.2

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.
@@ -75,8 +75,8 @@ class ErrorBoundary extends react_1.default.Component {
75
75
  }
76
76
  }
77
77
  }
78
- // do not apply suspense on already dynamic components
79
- if (this.props.isDynamic) {
78
+ // do not apply suspense when suspense is disabled or when on already dynamic components
79
+ if (this.props.disableSuspense || 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));
@@ -151,9 +151,10 @@ class PlaceholderCommon extends react_1.default.Component {
151
151
  const isByocWrapper = componentRendering.componentName === BYOCWrapper_1.BYOC_WRAPPER_RENDERING_NAME;
152
152
  // all dynamic elements will have a separate render prop
153
153
  const isDynamicComponent = !!((_a = component.render) === null || _a === void 0 ? void 0 : _a.preload);
154
+ const disableSuspense = this.props.disableSuspense || false;
154
155
  // wrapping with error boundary could cause problems in case where parent component uses withPlaceholder HOC and tries to access its children props
155
156
  // that's why we need to expose element's props here
156
- 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 }, rendered.props), rendered));
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));
157
158
  }
158
159
  // if editMode is equal to 'metadata' then emit shallow chromes for hydration in Pages
159
160
  if (((_b = this.props.sitecoreContext) === null || _b === void 0 ? void 0 : _b.editMode) === layout_1.EditMode.Metadata) {
@@ -244,4 +245,5 @@ PlaceholderCommon.propTypes = {
244
245
  ]),
245
246
  modifyComponentProps: prop_types_1.default.func,
246
247
  sitecoreContext: prop_types_1.default.object,
248
+ disableSuspense: prop_types_1.default.bool,
247
249
  };
@@ -50,8 +50,8 @@ class ErrorBoundary extends React.Component {
50
50
  }
51
51
  }
52
52
  }
53
- // do not apply suspense on already dynamic components
54
- if (this.props.isDynamic) {
53
+ // do not apply suspense when suspense is disabled or when on already dynamic components
54
+ if (this.props.disableSuspense || 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));
@@ -145,9 +145,10 @@ export class PlaceholderCommon extends React.Component {
145
145
  const isByocWrapper = componentRendering.componentName === BYOC_WRAPPER_RENDERING_NAME;
146
146
  // all dynamic elements will have a separate render prop
147
147
  const isDynamicComponent = !!((_a = component.render) === null || _a === void 0 ? void 0 : _a.preload);
148
+ const disableSuspense = this.props.disableSuspense || false;
148
149
  // wrapping with error boundary could cause problems in case where parent component uses withPlaceholder HOC and tries to access its children props
149
150
  // that's why we need to expose element's props here
150
- rendered = (React.createElement(ErrorBoundary, Object.assign({ key: rendered.type + '-' + index, errorComponent: this.props.errorComponent, componentLoadingMessage: this.props.componentLoadingMessage, type: type, isDynamic: isDynamicComponent || isByocWrapper }, rendered.props), rendered));
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));
151
152
  }
152
153
  // if editMode is equal to 'metadata' then emit shallow chromes for hydration in Pages
153
154
  if (((_b = this.props.sitecoreContext) === null || _b === void 0 ? void 0 : _b.editMode) === EditMode.Metadata) {
@@ -237,4 +238,5 @@ PlaceholderCommon.propTypes = {
237
238
  ]),
238
239
  modifyComponentProps: PropTypes.func,
239
240
  sitecoreContext: PropTypes.object,
241
+ disableSuspense: PropTypes.bool,
240
242
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sitecore-jss/sitecore-jss-react",
3
- "version": "22.7.0-canary.1",
3
+ "version": "22.7.0-canary.2",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "sideEffects": false,
@@ -62,14 +62,14 @@
62
62
  "react-dom": "^18.2.0"
63
63
  },
64
64
  "dependencies": {
65
- "@sitecore-jss/sitecore-jss": "22.7.0-canary.1",
65
+ "@sitecore-jss/sitecore-jss": "22.7.0-canary.2",
66
66
  "fast-deep-equal": "^3.1.3",
67
67
  "prop-types": "^15.8.1",
68
68
  "style-attr": "^1.3.0"
69
69
  },
70
70
  "description": "",
71
71
  "types": "types/index.d.ts",
72
- "gitHead": "31b27434eca1cdfcc402ad567b7ecff70670f675",
72
+ "gitHead": "ca9f11c61d1477426d308dc99369074a8e562a40",
73
73
  "files": [
74
74
  "dist",
75
75
  "types"
@@ -10,6 +10,7 @@ export type ErrorBoundaryProps = {
10
10
  sitecoreContext: SitecoreContextValue;
11
11
  type: string;
12
12
  isDynamic?: boolean;
13
+ disableSuspense?: boolean;
13
14
  errorComponent?: React.ComponentClass<ErrorComponentProps> | React.FC<ErrorComponentProps>;
14
15
  rendering?: ComponentRendering;
15
16
  componentLoadingMessage?: string;
@@ -66,6 +66,11 @@ export interface PlaceholderProps {
66
66
  * The message that gets displayed while component is loading
67
67
  */
68
68
  componentLoadingMessage?: string;
69
+ /**
70
+ * If true, disables Suspense for the placeholder.
71
+ * @default false
72
+ */
73
+ disableSuspense?: boolean;
69
74
  }
70
75
  export declare class PlaceholderCommon<T extends PlaceholderProps> extends React.Component<T> {
71
76
  static propTypes: {
@@ -81,6 +86,7 @@ export declare class PlaceholderCommon<T extends PlaceholderProps> extends React
81
86
  errorComponent: PropTypes.Requireable<NonNullable<React.ComponentClass<unknown, any> | React.FC<unknown>>>;
82
87
  modifyComponentProps: PropTypes.Requireable<(...args: any[]) => any>;
83
88
  sitecoreContext: PropTypes.Requireable<SitecoreContextValue>;
89
+ disableSuspense: PropTypes.Requireable<boolean>;
84
90
  };
85
91
  nodeRefs: Element[];
86
92
  state: Readonly<{