@ornikar/kitt-universal 25.55.0 → 25.56.0

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.
@@ -3655,6 +3655,8 @@ const ActionsItem = /*#__PURE__*/React.forwardRef(({
3655
3655
  }, ref) => {
3656
3656
  const [isLoading, setIsLoading] = React.useState(false);
3657
3657
  const mountedRef = React.useRef(false);
3658
+ // securing the loading state with a ref to avoid user action between rerenders
3659
+ const loadingRef = React.useRef(false);
3658
3660
 
3659
3661
  // effect just for tracking mounted state, as onPress can unmount the ActionButton
3660
3662
  React.useEffect(() => {
@@ -3672,15 +3674,18 @@ const ActionsItem = /*#__PURE__*/React.forwardRef(({
3672
3674
  icon: isLoading ? /*#__PURE__*/jsxRuntime.jsx(LoaderIcon, {}) : icon,
3673
3675
  onPress: e => {
3674
3676
  (async () => {
3675
- if (!onPress) return;
3677
+ if (!onPress || loadingRef.current) return;
3676
3678
  setIsLoading(true);
3679
+ loadingRef.current = true;
3677
3680
  try {
3678
3681
  await onPress(e);
3679
3682
  if (mountedRef.current) {
3680
3683
  setIsLoading(false);
3684
+ loadingRef.current = false;
3681
3685
  }
3682
3686
  } catch (error) {
3683
3687
  if (mountedRef.current) {
3688
+ loadingRef.current = false;
3684
3689
  setIsLoading(false);
3685
3690
  }
3686
3691
  throw error;