Function useAsyncEffect

  • Analogue of React.useEffect that can handle a Promise returned from the effect callback. Returned promise may resolve with a destructor / cleanup callback. An effect callback receives an AbortSignal that is aborted if effect is called again before the previously returned promise is resolved. Cleanup callbacks returned from the aborted effects are ignored.

    Parameters

    • effect: AsyncEffectCallback

      The callback that is invoked if deps have changed. An effect may return a destructor / cleanup callback. The previous effect is cleaned up before executing the next effect.

    • Optional deps: DependencyList

      The list of dependencies. If undefined then effect is called on every render.

    Returns void