@ornikar/kitt-universal 25.55.0 → 25.56.1-canary.d928591edd998e44393e1e007aac171879a3f90d.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.
@@ -3604,6 +3604,8 @@ const ActionsItem = /*#__PURE__*/forwardRef(({
3604
3604
  }, ref) => {
3605
3605
  const [isLoading, setIsLoading] = useState(false);
3606
3606
  const mountedRef = useRef(false);
3607
+ // securing the loading state with a ref to avoid user action between rerenders
3608
+ const loadingRef = useRef(false);
3607
3609
 
3608
3610
  // effect just for tracking mounted state, as onPress can unmount the ActionButton
3609
3611
  useEffect(() => {
@@ -3621,15 +3623,18 @@ const ActionsItem = /*#__PURE__*/forwardRef(({
3621
3623
  icon: isLoading ? /*#__PURE__*/jsx(LoaderIcon, {}) : icon,
3622
3624
  onPress: e => {
3623
3625
  (async () => {
3624
- if (!onPress) return;
3626
+ if (!onPress || loadingRef.current) return;
3625
3627
  setIsLoading(true);
3628
+ loadingRef.current = true;
3626
3629
  try {
3627
3630
  await onPress(e);
3628
3631
  if (mountedRef.current) {
3629
3632
  setIsLoading(false);
3633
+ loadingRef.current = false;
3630
3634
  }
3631
3635
  } catch (error) {
3632
3636
  if (mountedRef.current) {
3637
+ loadingRef.current = false;
3633
3638
  setIsLoading(false);
3634
3639
  }
3635
3640
  throw error;