kitchen-simulator 4.0.2-react-18 → 4.0.3-react-18
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/es/index.js +11 -10
- package/lib/index.js +11 -10
- package/package.json +1 -1
package/es/index.js
CHANGED
|
@@ -14,10 +14,12 @@ export function renderKitchenSimulator(container) {
|
|
|
14
14
|
if (!container) {
|
|
15
15
|
throw new Error('renderKitchenSimulator: container is required');
|
|
16
16
|
}
|
|
17
|
-
var root = null;
|
|
18
|
-
var setExternalEventFn = null;
|
|
19
17
|
|
|
20
|
-
//
|
|
18
|
+
// cache the root on the container so we never call createRoot twice
|
|
19
|
+
if (!container.__kitchenRoot) {
|
|
20
|
+
container.__kitchenRoot = createRoot(container);
|
|
21
|
+
}
|
|
22
|
+
var setExternalEventFn = null;
|
|
21
23
|
var Wrapper = /*#__PURE__*/function (_React$Component) {
|
|
22
24
|
function Wrapper(p) {
|
|
23
25
|
var _this;
|
|
@@ -46,17 +48,16 @@ export function renderKitchenSimulator(container) {
|
|
|
46
48
|
}
|
|
47
49
|
}]);
|
|
48
50
|
}(React.Component);
|
|
49
|
-
|
|
50
|
-
root.render(/*#__PURE__*/React.createElement(Wrapper, props));
|
|
51
|
+
container.__kitchenRoot.render(/*#__PURE__*/React.createElement(Wrapper, props));
|
|
51
52
|
return {
|
|
52
53
|
updateExternalEvent: function updateExternalEvent(newExternalEvent) {
|
|
53
|
-
|
|
54
|
-
(_setExternalEventFn = setExternalEventFn) === null || _setExternalEventFn === void 0 || _setExternalEventFn(newExternalEvent);
|
|
54
|
+
setExternalEventFn && setExternalEventFn(newExternalEvent);
|
|
55
55
|
},
|
|
56
56
|
unmount: function unmount() {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
if (container.__kitchenRoot) {
|
|
58
|
+
container.__kitchenRoot.unmount();
|
|
59
|
+
container.__kitchenRoot = null;
|
|
60
|
+
}
|
|
60
61
|
setExternalEventFn = null;
|
|
61
62
|
}
|
|
62
63
|
};
|
package/lib/index.js
CHANGED
|
@@ -22,10 +22,12 @@ function renderKitchenSimulator(container) {
|
|
|
22
22
|
if (!container) {
|
|
23
23
|
throw new Error('renderKitchenSimulator: container is required');
|
|
24
24
|
}
|
|
25
|
-
var root = null;
|
|
26
|
-
var setExternalEventFn = null;
|
|
27
25
|
|
|
28
|
-
//
|
|
26
|
+
// cache the root on the container so we never call createRoot twice
|
|
27
|
+
if (!container.__kitchenRoot) {
|
|
28
|
+
container.__kitchenRoot = (0, _client.createRoot)(container);
|
|
29
|
+
}
|
|
30
|
+
var setExternalEventFn = null;
|
|
29
31
|
var Wrapper = /*#__PURE__*/function (_React$Component) {
|
|
30
32
|
function Wrapper(p) {
|
|
31
33
|
var _this;
|
|
@@ -54,17 +56,16 @@ function renderKitchenSimulator(container) {
|
|
|
54
56
|
}
|
|
55
57
|
}]);
|
|
56
58
|
}(_react["default"].Component);
|
|
57
|
-
|
|
58
|
-
root.render(/*#__PURE__*/_react["default"].createElement(Wrapper, props));
|
|
59
|
+
container.__kitchenRoot.render(/*#__PURE__*/_react["default"].createElement(Wrapper, props));
|
|
59
60
|
return {
|
|
60
61
|
updateExternalEvent: function updateExternalEvent(newExternalEvent) {
|
|
61
|
-
|
|
62
|
-
(_setExternalEventFn = setExternalEventFn) === null || _setExternalEventFn === void 0 || _setExternalEventFn(newExternalEvent);
|
|
62
|
+
setExternalEventFn && setExternalEventFn(newExternalEvent);
|
|
63
63
|
},
|
|
64
64
|
unmount: function unmount() {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
if (container.__kitchenRoot) {
|
|
66
|
+
container.__kitchenRoot.unmount();
|
|
67
|
+
container.__kitchenRoot = null;
|
|
68
|
+
}
|
|
68
69
|
setExternalEventFn = null;
|
|
69
70
|
}
|
|
70
71
|
};
|