cockpit-plugin-base-react - v1.1.1
    Preparing search index...

    Function useAsyncAction

    • Wraps an async function with loading and error state.

      Type Parameters

      • T

      Parameters

      • action: () => Promise<T>

        The async function to execute. A new stable reference should be passed via useCallback to avoid unnecessary re-renders.

      Returns {
          clearError: () => void;
          error: string | null;
          execute: () => Promise<T | undefined>;
          loading: boolean;
      }

      An object with execute (calls the action), loading, error, and clearError (resets the error state).