create-async-component
npm i create-async-component
A factory function for creating asynchronous React components.
Quick Start
import * as React from 'react'import createAsyncComponent from 'create-async-component' const AsyncComponent = // Optionally preload the componentAsyncComponent // Use the component as you would any other component<AsyncComponent ='bar'/>
API
Argument | Type | Required? | Description |
---|---|---|---|
componentGetter | AsyncComponentGetter |
Yes | A function that returns a React component or a promise that resolves a React component |
options | AsyncComponentOptions |
No | Optionally adds loading and error state components. See AsyncComponentOptions |
AsyncComponent
Returns Preload your component
// Simply call its load() methodAsyncComponent.load// Real world example
AsyncComponentGetter
AsyncComponentOptions
AsyncComponent
LICENSE
MIT