v0.16.163 - 31.9 / 23.5

lazy

lazy is a promise loader. It is used when you want to display something while a promise is loading, or to run a callback after a promise is resolved.

  1. Allows to display/run something, or nothing while a promise is resolving.
  2. Allows to run a callback when the promise resolves.
  3. Allows to get notified of errors, and display/run something, or nothing. If wanted, a retry function is given for retrying the promise.
  4. It will render what the promise returns. If the promise returns a function it can be used as Component(props).

# Attributes

nametypedescription
fnfn/promisea function that returns a promise or a promise
[options.onLoading]anyrenders something while the promise resolves
[options.onLoaded]Functionruns a callback after the promise resolves
[options.onError]any | (e: Error, retry: Function) => void)renders something or runs a callback with the error object and a retry function as argument

# When not to use lazy

Lazy is not needed unless you use one of its options. You may use a promise directly as follows.

# Usage

All the different uses of Lazy