/** * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options */ import type { DependencyList } from 'react'; import { type AsyncCallbackState } from './useAsyncCallback.js'; /** * A hook that allows to execute an asynchronous function and provides the state of the execution. * The asynchronous function is executed immediately after the component is mounted. * * @param callback The asynchronous function to be executed. * @param deps The dependency list. * @returns The state of the execution. * * @example * ```tsx * const asyncFetchState = useAsyncValue( async () => { * const response = await fetch( 'https://api.example.com/data' ); * const data = await response.json(); * return data; * }, [] ); * * if ( asyncFetchState.status === 'loading' ) { * return
Loading...
; * } * * if ( asyncFetchState.status === 'success' ) { * return{ JSON.stringify( asyncFetchState.data, null, 2 ) };
* }
*
* if ( asyncFetchState.status === 'error' ) {
* return Error: { asyncFetchState.error.message }
; * } * ``` */ export declare const useAsyncValue: