# @manzano/use-is-pending

> Best UX pending indicator

Latest version **1.1.6** (published 2023-08-25) · ISC license · 0 weekly downloads

## Install

```sh
npm install @manzano/use-is-pending
pnpm add @manzano/use-is-pending
yarn add @manzano/use-is-pending
bun add @manzano/use-is-pending
```

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.6 |
| Published | 2023-08-25 |
| First published | 2023-08-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Mikaël ANZANO |
| Maintainers | manzano |
| Keywords | react, loading, hook, ux |

## Links

- npm: https://www.npmjs.com/package/@manzano/use-is-pending
- Repository: https://github.com/manzano78/use-is-pending
- Homepage: https://github.com/manzano78/use-is-pending#readme
- Issues: https://github.com/manzano78/use-is-pending/issues
- npm.io page: https://npm.io/package/@manzano/use-is-pending

## 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.6 (latest) — 2023-08-25
- 1.1.5 — 2023-08-25
- 1.1.4 — 2023-08-25
- 1.1.3 — 2023-08-25
- 1.1.2 — 2023-08-25

## README

# @manzano/use-is-pending

Tiny React hook for optimal UX pending indicators.

![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/manzano78/use-is-pending/ci.yml?style=flat-square)
[![npm version](https://img.shields.io/npm/v/@manzano/use-is-pending.svg?style=flat-square)](https://www.npmjs.com/package/@manzano/use-is-pending)

No flickering UI anymore!

- If your pending state lasts less than 800ms (by default), no pending indicator at all will be displayed to the user
- Otherwise, your pending indicator will start and last at least 1000ms (by default) even if your actual pending state ends before.

## Installation

```sh
# NPM
npm install @manzano/use-is-pending

# YARN
yarn add @manzano/use-is-pending
```

@manzano/use-is-pending 1.x.x requires **React 16.8.3 or later**.

### Usage

```tsx
import { useIsPending } from '@manzano/use-is-pending';

export function LoadingIndicator({
  isLoading: isActuallyPending,
}: {
  isLoading: boolean;
}) {
  const isPending = useIsPending(isActuallyPending);

  return isPending ? <div>Loading...</div> : null;
}
```

The hook takes your actual pending boolean variable as param and returns the UX optimized one.

### Options override

By default, the delay before activation is 800ms and the minimal duration is 1000ms. You can override these values by context provider.

Example:

```tsx
import { PendingOptionsProvider } from '@manzano/use-is-pending';

root.render(
  <PendingOptionsProvider delayBeforeActive={300} minActiveDuration={1500}>
    <App />
  </PendingOptionsProvider>,
);
```

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