All Projects → fdaciuk → load-async

fdaciuk / load-async

Licence: other
Load React components asynchronously

Programming Languages

javascript
184084 projects - #8 most used programming language

Load Async

Load React components asynchronously

Installation

yarn add load-async

or using NPM:

npm i --save load-async

Configuration

Add the load-async/src path on JS loader, inside the webpack config file.

Usage

import loadAsync from 'load-async'

const ContentAsync = loadAsync(import('./content'))

const App = () => (
  // will load a div until the component is ready
  <ContentAsync />
)

You can use children if you want to:

import loadAsync from 'load-async'
import Header from './header'

const MainAsync = loadAsync(import('./main'))

const App = () => (
  <MainAsync>
    <Header />
  </MainAsync>
)

License

MIT © Fernando Daciuk

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].