@xylabs/sdk-react
    Preparing search index...

    Variable usePromiseConst

    usePromise: <TResult>(
        promise: () => Promise<TResult | undefined>,
        dependencies: DependencyList,
        config?: UsePromiseConfig<TResult>,
    ) => [TResult | undefined, Error | undefined, UsePromiseState | undefined]

    A custom hook that manages the state of a promise, including its result, error, and state.

    Type Declaration

      • <TResult>(
            promise: () => Promise<TResult | undefined>,
            dependencies: DependencyList,
            config?: UsePromiseConfig<TResult>,
        ): [TResult | undefined, Error | undefined, UsePromiseState | undefined]
      • Type Parameters

        • TResult

          The type of the result that the promise resolves to.

        Parameters

        • promise: () => Promise<TResult | undefined>

          A function that returns a promise.

        • dependencies: DependencyList

          An array of dependencies that will trigger the promise to be re-evaluated when changed.

        • Optionalconfig: UsePromiseConfig<TResult>

          Optional configuration for the hook.

          Configuration options for the usePromise hook.

          • Optionaldebug?: string

            Optional debug string for logging purposes.

          • OptionaldefaultValue?: TResult

            Optional default value to be used before the promise resolves.

        Returns [TResult | undefined, Error | undefined, UsePromiseState | undefined]

        An array containing the result of the promise, any error that occurred, and the current state of the promise.