@doist/reactist 28.2.0 → 28.2.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/dist/reactist.cjs.development.js +10 -11
- package/dist/reactist.cjs.development.js.map +1 -1
- package/dist/reactist.cjs.production.min.js +1 -1
- package/dist/reactist.cjs.production.min.js.map +1 -1
- package/es/toast/use-toasts.js +10 -11
- package/es/toast/use-toasts.js.map +1 -1
- package/lib/toast/use-toasts.js +1 -1
- package/lib/toast/use-toasts.js.map +1 -1
- package/package.json +1 -1
|
@@ -1453,25 +1453,24 @@ const InternalToast = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
1453
1453
|
onDismiss,
|
|
1454
1454
|
onRemoveToast
|
|
1455
1455
|
}, ref) {
|
|
1456
|
-
const [timeoutRunning, setTimeoutRunning] = React__default["default"].useState(Boolean(autoDismissDelay));
|
|
1457
1456
|
const timeoutRef = React__default["default"].useRef();
|
|
1457
|
+
const removeToast = React__default["default"].useCallback(function removeToast() {
|
|
1458
|
+
onRemoveToast(toastId);
|
|
1459
|
+
onDismiss == null ? void 0 : onDismiss();
|
|
1460
|
+
}, [onDismiss, onRemoveToast, toastId]);
|
|
1458
1461
|
const startTimeout = React__default["default"].useCallback(function startTimeout() {
|
|
1459
|
-
|
|
1460
|
-
|
|
1462
|
+
if (!autoDismissDelay) return;
|
|
1463
|
+
timeoutRef.current = window.setTimeout(removeToast, autoDismissDelay * 1000);
|
|
1464
|
+
}, [autoDismissDelay, removeToast]);
|
|
1461
1465
|
const stopTimeout = React__default["default"].useCallback(function stopTimeout() {
|
|
1462
|
-
setTimeoutRunning(false);
|
|
1463
1466
|
clearTimeout(timeoutRef.current);
|
|
1464
1467
|
timeoutRef.current = undefined;
|
|
1465
1468
|
}, []);
|
|
1466
|
-
const removeToast = React__default["default"].useCallback(function removeToast() {
|
|
1467
|
-
onRemoveToast(toastId);
|
|
1468
|
-
onDismiss == null ? void 0 : onDismiss();
|
|
1469
|
-
}, [onDismiss, onRemoveToast, toastId]);
|
|
1470
1469
|
React__default["default"].useEffect(function setupAutoDismiss() {
|
|
1471
|
-
|
|
1472
|
-
|
|
1470
|
+
stopTimeout();
|
|
1471
|
+
startTimeout();
|
|
1473
1472
|
return stopTimeout;
|
|
1474
|
-
}, [
|
|
1473
|
+
}, [startTimeout, stopTimeout]);
|
|
1475
1474
|
/**
|
|
1476
1475
|
* If the action is toast action object and not a custom element,
|
|
1477
1476
|
* the `onClick` property is wrapped in another handler responsible
|