# @ozylog/async-component

> Simple Async Component for React

Latest version **0.1.2** (published 2017-08-14) · SEE LICENSE IN LICENSE license · 0 weekly downloads

## Install

```sh
npm install @ozylog/async-component
pnpm add @ozylog/async-component
yarn add @ozylog/async-component
bun add @ozylog/async-component
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2017-08-14 |
| First published | 2017-08-14 |
| Weekly downloads | 0 |
| License | SEE LICENSE IN LICENSE |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Cahya Pribadi |
| Maintainers | cahyap |
| Keywords | ozylog, react, async, component, HOC |

## Links

- npm: https://www.npmjs.com/package/@ozylog/async-component
- Repository: https://github.com/ozylog/async-component
- Homepage: https://github.com/ozylog/async-component#readme
- Issues: https://github.com/ozylog/async-component/issues
- npm.io page: https://npm.io/package/@ozylog/async-component

## 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

- 0.1.2 (latest) — 2017-08-14
- 0.1.1 — 2017-08-14
- 0.1.0 — 2017-08-14

## README

# async-component
Simple Async Component for React

[![Travis](https://img.shields.io/travis/ozylog/async-component.svg)](https://travis-ci.org/ozylog/async-component) [![npm](https://img.shields.io/npm/dt/@ozylog/async-component.svg)](https://www.npmjs.com/package/@ozylog/async-component)

## Installation
```
npm install @ozylog/async-component
```

## Usage Example
```javascript
'use react';

import createAsyncComponent from '@ozylog/async-component';
import DashboardLoaderComponent from './DashboardLoaderComponent';
import {isAuthenticated} from './authApi';

const DashboardContainer = createAsyncComponent({
  getComponent: async () => {
    let component;

    try {
      const isAuth = await isAuthenticated();

      if (isAuth) {
        component = await System.import('./../containers/DashboardContainer');
      } else {
        component = await System.import('./../components/ErrorForbiddenComponent');
      }
    } catch (err) {
      component = await System.import('./../components/ErrorInternalServerComponent');
    }

    return component;
  },
  LoaderComponent: DashboardLoaderComponent
});

export default (
  <Route path='/dashboard' render={() => <DashboardContainer />} />
);
```

## License
MIT

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