# get-component-async

> load component async for react router

Latest version **1.1.0** (published 2019-01-02) · ISC license · 0 weekly downloads

## Install

```sh
npm install get-component-async
pnpm add get-component-async
yarn add get-component-async
bun add get-component-async
```

## 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.1.0 |
| Published | 2019-01-02 |
| First published | 2017-12-29 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 8.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | gwuhaolin |
| Maintainers | gwuhaolin |
| Keywords | react, router, component, async, load, webpack |

## Links

- npm: https://www.npmjs.com/package/get-component-async
- npm.io page: https://npm.io/package/get-component-async

## Dependencies (3)

- [react](https://npm.io/package/react.md) *
- [tslib](https://npm.io/package/tslib.md) *
- [@types/react](https://npm.io/package/@types/react.md) *

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2019-01-02
- 1.0.7 — 2018-12-26
- 1.0.6 — 2018-12-26
- 1.0.5 — 2018-12-26
- 1.0.4 — 2018-03-22
- 1.0.3 — 2018-03-21
- 1.0.2 — 2018-03-21
- 1.0.1 — 2018-01-02
- 1.0.0 — 2017-12-29

## README

# get-component-async

load component async for react router

## Use

install by:

```bash
npm i -S get-component-async
```

#### For react router

```jsx harmony
import getComponentAsync from "get-component-async";

<HashRouter>
  <Route
    path="/sub"
    component={getComponentAsync(
      // webpack code split
      () => import("./sub")
    )}
  />
</HashRouter>;
```

`./sub` is code is:

```jsx harmony
export default class Sub extends Component {
  render() {
    return <div>sub</div>;
  }
}
```

#### For big component

```jsx harmony
import { getElementAsync } from "get-component-async";

<div>
  ...others
  {getElementAsync(() => import("./bigComponent"))}
</div>;
```

#### Show loading before loaded

```jsx harmony
import { getElementAsync } from "get-component-async";

<div>
  ...others
  {getElementAsync(() => import("./bigComponent"), <Loading />, props)}
</div>;
```

#### Set default loading before loaded

```jsx harmony
import { setDefaultLoading } from "get-component-async";

setDefaultLoading(<Loading />);
```

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