brew-js-react 0.3.1 → 0.3.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.
package/dialog.js CHANGED
@@ -1,19 +1,18 @@
1
1
  import { createElement, useEffect, useState } from "react";
2
2
  import ReactDOM from "react-dom";
3
+ import ReactDOMClient from "./include/external/react-dom-client.js";
3
4
  import { always, catchAsync, either, extend, makeAsync, noop, pipe } from "./include/zeta-dom/util.js";
4
5
  import { containsOrEquals, removeNode } from "./include/zeta-dom/domUtil.js";
5
6
  import dom from "./include/zeta-dom/dom.js";
6
7
  import { lock, preventLeave } from "./include/zeta-dom/domLock.js";
7
8
  import { closeFlyout, openFlyout } from "./include/brew-js/domAction.js";
8
9
 
9
- const createRoot = ReactDOM.createRoot;
10
-
11
10
  /**
12
11
  * @param {Partial<import("./dialog").DialogOptions<any>>} props
13
12
  */
14
13
  export function createDialog(props) {
15
14
  var root = document.createElement('div');
16
- var reactRoot = createRoot && createRoot(root);
15
+ var reactRoot = ReactDOMClient.createRoot(root);
17
16
  var closeDialog = closeFlyout.bind(0, root);
18
17
  var promise;
19
18
 
@@ -21,11 +20,7 @@ export function createDialog(props) {
21
20
  removeNode(root);
22
21
  (props.onClose || noop)(root);
23
22
  if (props.onRender) {
24
- if (reactRoot) {
25
- reactRoot.unmount();
26
- } else {
27
- ReactDOM.unmountComponentAtNode(root);
28
- }
23
+ reactRoot.unmount();
29
24
  }
30
25
  });
31
26
 
@@ -55,11 +50,7 @@ export function createDialog(props) {
55
50
  if (props.wrapper) {
56
51
  content = createElement(props.wrapper, dialogProps, content);
57
52
  }
58
- if (reactRoot) {
59
- reactRoot.render(content);
60
- } else {
61
- ReactDOM.render(content, root);
62
- }
53
+ reactRoot.render(content);
63
54
  }
64
55
  promise = openFlyout(root);
65
56
  if (props.preventLeave) {