# react-lazyable

> use react suspense and lazy api to async loading component, support antd component

Latest version **1.0.6** (published 2019-04-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-lazyable
pnpm add react-lazyable
yarn add react-lazyable
bun add react-lazyable
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2019-04-03 |
| First published | 2019-03-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 11.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | carlzhang |

## Links

- npm: https://www.npmjs.com/package/react-lazyable
- npm.io page: https://npm.io/package/react-lazyable

## Dependencies (2)

- [react](https://npm.io/package/react.md) ^16.8.4
- [hoist-non-react-statics](https://npm.io/package/hoist-non-react-statics.md) ^3.3.0

## Recent versions

- 1.0.6 (latest) — 2019-04-03
- 1.0.5 — 2019-04-03
- 1.0.4 — 2019-04-03
- 1.0.3 — 2019-04-03
- 1.0.2 — 2019-03-21
- 1.0.1 — 2019-03-14
- 1.0.0 — 2019-03-11

## README

# Welcome to React-Lazyable!

Use react **suspense** and **lazy**  to async loading component, support **[antd](https://ant.design/)** components.
Thanks for **[react code splitting](https://reactjs.org/docs/code-splitting.html)**, **[loadable-components](https://github.com/smooth-code/loadable-components)** and  **[react-loadable](https://github.com/jamiebuilds/react-loadable)**. 
If you want to do code-splitting in a server rendered app or require other features, please use the components mentioned above.

## Install
```sh
npm i react-lazyable
yarn add react-lazyable
```
## Example
```js
import * as React from "react";
import { loadable } from "react-lazyable";

const LoadableComponent= loadable({
    loader:() => import('./my-component')
})

export default class OtherComponent extends React.Component {
    render(){
        const props = {
            prop1:'',
            prop2:'',
        };
        const children = this.props.children;
        return <LoadableComponent{...props}>{children}</LoadableComponent>
    }
}
```
## Options

### loader (*required*)
required.
```
lazyload({loader:() => import('react-component')})
lazyload({loader:() => import('./my-component')})
```
### loading  (*optional*)
```
lazyload({
    loader:() => import('react-component'),
    loading:() => <loading/>
})
```
### delay (*optional*)
```
lazyload({
    loader:() => import('react-component'),
    delay:1000
})
```
### export (*optional*)
```
lazyload({
    loader:() => import('react-component'),
    export:(d) => d.wantExport || d.default
})
```
### forwardRef (*optional*)
If you want to get ref manually, set forwardRef to true. 

### identifier (*optional*)
Set component's identifier name.

### statics (*optional*)
The option using for antd component static propertise, use [babel-plugin-import-antd-async](https://github.com/grapecitycarlzhang/babel-plugin-import-antd-async) for it.

---
_Source: https://npm.io/package/react-lazyable · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
