Function unstable_useAsyncEffect

  • Experimental

    React hook to run an asynchronous effect whenever the component mounts, cleaning up when it unmounts.

    Type Parameters

    • T

      The type of the effect value.

    Parameters

    • fn: () => AsyncGenerator<Dependency, T>

      An async generator representing the effect logic.

    Returns void

    useAsyncEffect(async function* () {
    yield someDependency;
    console.log('Async side effect complete!');
    });