An open API service indexing awesome lists of open source software.

https://github.com/hyy1115/lazy-load-component

提供webpack异步加载React组件的高阶函数
https://github.com/hyy1115/lazy-load-component

async lazy lazyload react webpack

Last synced: about 1 year ago
JSON representation

提供webpack异步加载React组件的高阶函数

Awesome Lists containing this project

README

          

# lazy-load-component

### 安装
```node
npm i --save lazy-load-component
```

### 用法
如果你的react项目使用了webpack,那么可以使用lazyLoadComponent实现代码切割。
```javascript
import lazyLoadComponent from 'lazy-load-component'

const Login = lazyLoadComponent(() => import('./containers/Login'))
```

### 语法
lazyLoadComponent支持传入一个Promise属性的函数。
```javascript
lazyLoadComponent(fn)
```

### 注意事项
你的react组件必须包含default导出模块。