@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.
@@ -3632,6 +3632,8 @@ const ActionsItem = /*#__PURE__*/forwardRef(({
3632
3632
  }, ref) => {
3633
3633
  const [isLoading, setIsLoading] = useState(false);
3634
3634
  const mountedRef = useRef(false);
3635
+ // securing the loading state with a ref to avoid user action between rerenders
3636
+ const loadingRef = useRef(false);
3635
3637
 
3636
3638
  // effect just for tracking mounted state, as onPress can unmount the ActionButton
3637
3639
  useEffect(() => {
@@ -3649,15 +3651,18 @@ const ActionsItem = /*#__PURE__*/forwardRef(({
3649
3651
  icon: isLoading ? /*#__PURE__*/jsx(LoaderIcon, {}) : icon,
3650
3652
  onPress: e => {
3651
3653
  (async () => {
3652
- if (!onPress) return;
3654
+ if (!onPress || loadingRef.current) return;
3653
3655
  setIsLoading(true);
3656
+ loadingRef.current = true;
3654
3657
  try {
3655
3658
  await onPress(e);
3656
3659
  if (mountedRef.current) {
3657
3660
  setIsLoading(false);
3661
+ loadingRef.current = false;
3658
3662
  }
3659
3663
  } catch (error) {
3660
3664
  if (mountedRef.current) {
3665
+ loadingRef.current = false;
3661
3666
  setIsLoading(false);
3662
3667
  }
3663
3668
  throw error;