# react-delay-fallback

> React component to delay children rendering and show a fallback component while waiting

Latest version **2.0.0** (published 2022-03-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-delay-fallback
pnpm add react-delay-fallback
yarn add react-delay-fallback
bun add react-delay-fallback
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2022-03-22 |
| First published | 2020-07-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=8.0.0 |
| Dependencies | 0 |
| Unpacked size | 10.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jonathan Mataloni |
| Maintainers | jonathanmataloni |
| Keywords | react, delay, fallback, wait, render, suspend, defer |

## Links

- npm: https://www.npmjs.com/package/react-delay-fallback
- Repository: https://github.com/jonamat/react-delay-fallback
- Homepage: https://github.com/jonamat/react-delay-fallback#readme
- Issues: https://github.com/jonamat/react-delay-fallback/issues
- npm.io page: https://npm.io/package/react-delay-fallback

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

- 2.0.0 (latest) — 2022-03-22
- 1.0.2 — 2020-08-01
- 1.0.1 — 2020-07-28
- 1.0.0 — 2020-07-27

## README

# react-delay-fallback

![version](https://img.shields.io/npm/v/react-delay-fallback)
![size](https://img.shields.io/bundlephobia/min/react-delay-fallback)
![download](https://img.shields.io/npm/dm/react-delay-fallback)

React component to delay children rendering and show a fallback component while waiting

## Installation

```cli
npm i react-delay-fallback
```

## Compatibility

Compatible with React >=16.8.0\
Compatible with Node >=8.0.0

## Features
- Extremely small: uses react hooks and will occupying less than 2kb in your final bundle
- Safe unmounting: clears timers and listeners at unmounting

### Other features
- Runtime type checking with prop-types and static with typescript declaration files
- Exhaustive doc comments
- Tree shakable: exported with ESM modules
- Tested with available coverage report

## API

Index

[Delay](#Delay)

---

#### Delay

```import { Delay } from 'react-delay-fallback```

Type: `FunctionComponent`

| Prop        | Type        | Default     | Usage                                                 |
| ----------- | ----------- | ----------- | ----------------------------------------------------- |
| `timeout`?  | `number`    | `0`         | Time in milliseconds for rendering                    |
| `fallback`? | `ReactNode` | `undefined` | Component to render instead of children while waiting |
| `onRender`? | `Function`  | `undefined` | Function to trigger on render                         |

---

## Usage examples

```jsx
import { Delay } from 'react-delay-fallback';

function App() {
    const handleOnRender = () => window.alert('Callback invoked at rendering');

    return (
        <Delay
        timeout={5000}
        fallback={<span>Wait a moment...</span>} // <-- this will be rendered while page is loading
        onRender={handleOnRender}>
            <h1>This</h1>
            <p>Will appear after 5 seconds</p>
        </Delay>
    );
}

```

## Dependencies

No dependencies

### Peer dependencies
- React: ^16.8.0
- ReactDOM: ^15.6.2

## License
MIT

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