Function Lazy

  • Use this component for lazy importing other components.

    Parameters

    • props: {
          children: (() => Promise<ElementChildren>);
          else?: ElementChildren;
          onError?: ((error) => void);
      }
      • children: (() => Promise<ElementChildren>)

        Async function for that resolves to an element.

      • Optional else?: ElementChildren

        Element to show until the promise resolves.

      • Optional onError?: ((error) => void)

        Error handler which is executed if the promise is rejected.

          • (error): void
          • Parameters

            • error: any

            Returns void

    Returns JSX.Element

    Example

    <Lazy else='loading...'>{() => import('./my-component').then(m => <m.MyComponent/>)}</Lazy>