@mezzanine-ui/react 1.0.0 → 1.0.1
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/Notifier/createNotifier.js +10 -4
- package/package.json +1 -1
|
@@ -11,20 +11,26 @@ import NotifierManager from './NotifierManager.js';
|
|
|
11
11
|
*/
|
|
12
12
|
function createNotifier(props) {
|
|
13
13
|
const { config: configProp, render: renderNotifier, setRoot, duration, maxCount, renderContainer, sortBeforeUpdate, ...restNotifierProps } = props;
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
let container = null;
|
|
15
|
+
let root = null;
|
|
16
16
|
const controllerRef = createRef();
|
|
17
17
|
let currentConfig = {
|
|
18
18
|
duration,
|
|
19
19
|
maxCount,
|
|
20
20
|
...configProp,
|
|
21
21
|
};
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
function ensureInitialized() {
|
|
23
|
+
if (container || typeof document === 'undefined')
|
|
24
|
+
return;
|
|
25
|
+
container = document.createElement('div');
|
|
26
|
+
if (setRoot)
|
|
27
|
+
setRoot(container);
|
|
28
|
+
root = createRoot(container);
|
|
24
29
|
}
|
|
25
30
|
return {
|
|
26
31
|
add(notifier) {
|
|
27
32
|
var _a, _b;
|
|
33
|
+
ensureInitialized();
|
|
28
34
|
if (container === null)
|
|
29
35
|
return 'NOT_SET';
|
|
30
36
|
document.body.appendChild(container);
|