kitzo 2.0.2 → 2.0.4
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/README.md +1 -1
- package/dist/react.esm.js +10 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ npm i kitzo
|
|
|
25
25
|
or
|
|
26
26
|
|
|
27
27
|
```javascript
|
|
28
|
-
<script src="https://cdn.jsdelivr.net/npm/kitzo@2.0.
|
|
28
|
+
<script src="https://cdn.jsdelivr.net/npm/kitzo@2.0.4/dist/kitzo.umd.min.js"></script>
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
> Attach this script tag in the html head tag and you are good to go.
|
package/dist/react.esm.js
CHANGED
|
@@ -386,6 +386,7 @@ function ToastContainer(props) {
|
|
|
386
386
|
} = props;
|
|
387
387
|
const [toasts, setToasts] = useState([]);
|
|
388
388
|
useEffect(() => {
|
|
389
|
+
const timeouts = new Set();
|
|
389
390
|
const unsub = subscribe(toast => {
|
|
390
391
|
const duration = toast.options.duration;
|
|
391
392
|
const id = toast.options.id;
|
|
@@ -405,18 +406,24 @@ function ToastContainer(props) {
|
|
|
405
406
|
}, ...prev];
|
|
406
407
|
});
|
|
407
408
|
if (toast.type !== 'loading') {
|
|
408
|
-
setTimeout(() => {
|
|
409
|
+
const exit = setTimeout(() => {
|
|
409
410
|
setToasts(prev => prev.map(t => t.options.id === id ? {
|
|
410
411
|
...t,
|
|
411
412
|
leaving: true
|
|
412
413
|
} : t));
|
|
413
414
|
}, Math.max(0, duration - 300));
|
|
414
|
-
setTimeout(() => {
|
|
415
|
+
const remove = setTimeout(() => {
|
|
415
416
|
setToasts(prev => prev.filter(t => t.options.id !== id));
|
|
416
417
|
}, duration);
|
|
418
|
+
timeouts.add(exit);
|
|
419
|
+
timeouts.add(remove);
|
|
417
420
|
}
|
|
418
421
|
});
|
|
419
|
-
return () =>
|
|
422
|
+
return () => {
|
|
423
|
+
unsub();
|
|
424
|
+
timeouts.forEach(clearTimeout);
|
|
425
|
+
timeouts.clear();
|
|
426
|
+
};
|
|
420
427
|
}, []);
|
|
421
428
|
return /*#__PURE__*/React.createElement("div", {
|
|
422
429
|
style: {
|