ecomlab-components-next 0.1.225 → 0.1.226
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.
|
@@ -43,14 +43,19 @@ var AdvantagesBlock = function AdvantagesBlock(_ref) {
|
|
|
43
43
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
44
44
|
maxHeight = _useState4[0],
|
|
45
45
|
setMaxHeight = _useState4[1];
|
|
46
|
-
var _useState5 = (0, _react.useState)(
|
|
46
|
+
var _useState5 = (0, _react.useState)(0),
|
|
47
47
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
48
48
|
windowWidth = _useState6[0],
|
|
49
|
-
setWindowWidth = _useState6[1];
|
|
49
|
+
setWindowWidth = _useState6[1]; // ✅ Инициализируем 0
|
|
50
50
|
var _useState7 = (0, _react.useState)(false),
|
|
51
51
|
_useState8 = _slicedToArray(_useState7, 2),
|
|
52
52
|
isReady = _useState8[0],
|
|
53
53
|
setIsReady = _useState8[1];
|
|
54
|
+
var _useState9 = (0, _react.useState)(false),
|
|
55
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
56
|
+
isClient = _useState10[0],
|
|
57
|
+
setIsClient = _useState10[1]; // ✅ Новое состояние для проверки клиента
|
|
58
|
+
|
|
54
59
|
var setHeight = (0, _react.useCallback)(function () {
|
|
55
60
|
if (blocksRef.current.length === 0 || !isReady) return;
|
|
56
61
|
var heights = blocksRef.current.filter(function (block) {
|
|
@@ -66,20 +71,19 @@ var AdvantagesBlock = function AdvantagesBlock(_ref) {
|
|
|
66
71
|
}
|
|
67
72
|
}, [isReady, maxHeight]);
|
|
68
73
|
(0, _react.useEffect)(function () {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
74
|
+
// ✅ Устанавливаем флаг, что мы на клиенте
|
|
75
|
+
setIsClient(true);
|
|
76
|
+
setRefPage("?ref_page=".concat(window.location.href));
|
|
77
|
+
setWindowWidth(window.innerWidth);
|
|
73
78
|
}, []);
|
|
74
79
|
(0, _react.useEffect)(function () {
|
|
75
|
-
if (
|
|
80
|
+
if (!isClient) return; // ✅ Не выполняем на сервере
|
|
81
|
+
|
|
76
82
|
var handleResize = function handleResize() {
|
|
77
83
|
setWindowWidth(window.innerWidth);
|
|
78
84
|
setHeight();
|
|
79
85
|
};
|
|
80
86
|
window.addEventListener("resize", handleResize);
|
|
81
|
-
|
|
82
|
-
// Ждем полной загрузки страницы включая шрифты
|
|
83
87
|
if (document.readyState === 'complete') {
|
|
84
88
|
setIsReady(true);
|
|
85
89
|
} else {
|
|
@@ -93,10 +97,11 @@ var AdvantagesBlock = function AdvantagesBlock(_ref) {
|
|
|
93
97
|
return setIsReady(true);
|
|
94
98
|
});
|
|
95
99
|
};
|
|
96
|
-
}, [setHeight]);
|
|
100
|
+
}, [setHeight, isClient]); // ✅ Добавляем isClient в зависимости
|
|
101
|
+
|
|
97
102
|
(0, _react.useEffect)(function () {
|
|
98
|
-
if (isReady) {
|
|
99
|
-
//
|
|
103
|
+
if (isReady && isClient) {
|
|
104
|
+
// ✅ Проверяем isClient
|
|
100
105
|
var attempts = [0, 100, 300, 500];
|
|
101
106
|
attempts.forEach(function (delay) {
|
|
102
107
|
setTimeout(function () {
|
|
@@ -104,14 +109,28 @@ var AdvantagesBlock = function AdvantagesBlock(_ref) {
|
|
|
104
109
|
}, delay);
|
|
105
110
|
});
|
|
106
111
|
}
|
|
107
|
-
}, [isReady, setHeight, list.length]);
|
|
108
|
-
|
|
109
|
-
// Обновляем высоту при изменении контента
|
|
112
|
+
}, [isReady, setHeight, list.length, isClient]);
|
|
110
113
|
(0, _react.useEffect)(function () {
|
|
111
|
-
if (isReady) {
|
|
114
|
+
if (isReady && isClient) {
|
|
115
|
+
// ✅ Проверяем isClient
|
|
112
116
|
setHeight();
|
|
113
117
|
}
|
|
114
|
-
}, [list, isReady, setHeight]);
|
|
118
|
+
}, [list, isReady, setHeight, isClient]);
|
|
119
|
+
|
|
120
|
+
// ✅ Ранний возврат для серверного рендеринга
|
|
121
|
+
if (!isClient) {
|
|
122
|
+
return /*#__PURE__*/_react["default"].createElement("section", {
|
|
123
|
+
className: "advantages-block ".concat(className)
|
|
124
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
125
|
+
className: "advantages-block__header"
|
|
126
|
+
}, title && /*#__PURE__*/_react["default"].createElement("h2", {
|
|
127
|
+
className: "advantages-block__title"
|
|
128
|
+
}, title), description && /*#__PURE__*/_react["default"].createElement("p", {
|
|
129
|
+
className: "advantages-block__description"
|
|
130
|
+
}, description)), descriptionWhite && /*#__PURE__*/_react["default"].createElement("p", {
|
|
131
|
+
className: "advantages-block__description-white"
|
|
132
|
+
}, descriptionWhite));
|
|
133
|
+
}
|
|
115
134
|
return /*#__PURE__*/_react["default"].createElement("section", {
|
|
116
135
|
className: "advantages-block ".concat(className)
|
|
117
136
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
@@ -143,7 +162,6 @@ var AdvantagesBlock = function AdvantagesBlock(_ref) {
|
|
|
143
162
|
ref: function ref(el) {
|
|
144
163
|
blocksRef.current[index] = el;
|
|
145
164
|
if (el && isReady) {
|
|
146
|
-
// Обновляем высоту при изменении ref
|
|
147
165
|
setTimeout(setHeight, 0);
|
|
148
166
|
}
|
|
149
167
|
}
|